Просмотр исходного кода

[Console] decoupled Command from Application

Fabien Potencier 14 лет назад
Родитель
Сommit
6ab11eb1ce
1 измененных файлов с 24 добавлено и 1 удалено
  1. 24 1
      src/Symfony/Component/Console/Command/Command.php

+ 24 - 1
src/Symfony/Component/Console/Command/Command.php

@@ -17,6 +17,7 @@ use Symfony\Component\Console\Input\InputArgument;
 use Symfony\Component\Console\Input\InputInterface;
 use Symfony\Component\Console\Input\InputInterface;
 use Symfony\Component\Console\Output\OutputInterface;
 use Symfony\Component\Console\Output\OutputInterface;
 use Symfony\Component\Console\Application;
 use Symfony\Component\Console\Application;
+use Symfony\Component\Console\Helper\HelperSet;
 
 
 /**
 /**
  * Base class for all commands.
  * Base class for all commands.
@@ -37,6 +38,7 @@ class Command
     private $applicationDefinitionMerged;
     private $applicationDefinitionMerged;
     private $code;
     private $code;
     private $synopsis;
     private $synopsis;
+    private $helperSet;
 
 
     /**
     /**
      * Constructor.
      * Constructor.
@@ -75,6 +77,27 @@ class Command
     public function setApplication(Application $application = null)
     public function setApplication(Application $application = null)
     {
     {
         $this->application = $application;
         $this->application = $application;
+        $this->setHelperSet($application->getHelperSet());
+    }
+
+    /**
+     * Sets the helper set.
+     *
+     * @param HelperSet $helperSet A HelperSet instance
+     */
+    public function setHelperSet(HelperSet $helperSet)
+    {
+        $this->helperSet = $helperSet;
+    }
+
+    /**
+     * Gets the helper set.
+     *
+     * @return HelperSet A HelperSet instance
+     */
+    public function getHelperSet()
+    {
+        return $this->helperSet;
     }
     }
 
 
     /**
     /**
@@ -474,7 +497,7 @@ class Command
      */
      */
     public function getHelper($name)
     public function getHelper($name)
     {
     {
-        return $this->application->getHelperSet()->get($name);
+        return $this->helperSet->get($name);
     }
     }
 
 
     /**
     /**