Skip to content

Commit

Permalink
[Console] decoupled Command from Application
Browse files Browse the repository at this point in the history
  • Loading branch information
fabpot committed Jun 20, 2011
1 parent 25e99e8 commit 6ab11eb
Showing 1 changed file with 24 additions and 1 deletion.
25 changes: 24 additions & 1 deletion src/Symfony/Component/Console/Command/Command.php
Expand Up @@ -17,6 +17,7 @@
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;
use Symfony\Component\Console\Application;
use Symfony\Component\Console\Helper\HelperSet;

/**
* Base class for all commands.
Expand All @@ -37,6 +38,7 @@ class Command
private $applicationDefinitionMerged;
private $code;
private $synopsis;
private $helperSet;

/**
* Constructor.
Expand Down Expand Up @@ -75,6 +77,27 @@ public function __construct($name = null)
public function setApplication(Application $application = null)
{
$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;
}

/**
Expand Down Expand Up @@ -474,7 +497,7 @@ public function getSynopsis()
*/
public function getHelper($name)
{
return $this->application->getHelperSet()->get($name);
return $this->helperSet->get($name);
}

/**
Expand Down

0 comments on commit 6ab11eb

Please sign in to comment.