From e055058cb40301974ec7f2093b84ed1a3dba79e9 Mon Sep 17 00:00:00 2001 From: Manuel Raynaud Date: Mon, 3 Jun 2013 15:29:01 +0200 Subject: [PATCH] import ContainerAwareCommand from SymfonyFramework bundle --- .../Thelia/Command/ContainerAwareCommand.php | 60 +++++++++++++++++++ 1 file changed, 60 insertions(+) create mode 100644 core/lib/Thelia/Command/ContainerAwareCommand.php diff --git a/core/lib/Thelia/Command/ContainerAwareCommand.php b/core/lib/Thelia/Command/ContainerAwareCommand.php new file mode 100644 index 000000000..abd8f9960 --- /dev/null +++ b/core/lib/Thelia/Command/ContainerAwareCommand.php @@ -0,0 +1,60 @@ +. */ +/* */ +/*************************************************************************************/ + +namespace Thelia\Command; + +use Symfony\Component\Console\Command\Command; +use Symfony\Component\DependencyInjection\ContainerInterface; +use Symfony\Component\DependencyInjection\ContainerAwareInterface; + +/** + * Command. + * + * @author Fabien Potencier + */ +class ContainerAwareCommand extends Command implements ContainerAwareInterface { + /** + * @var ContainerInterface + */ + private $container; + + /** + * @return ContainerInterface + */ + protected function getContainer() + { + if (null === $this->container) { + $this->container = $this->getApplication()->getKernel()->getContainer(); + } + + return $this->container; + } + + /** + * @see ContainerAwareInterface::setContainer() + */ + public function setContainer(ContainerInterface $container = null) + { + $this->container = $container; + } +} \ No newline at end of file