From 8ea5c4c0f614efa0f5fb63353c0ffcf99f2a8e8d Mon Sep 17 00:00:00 2001 From: Kevin Vergauwen Date: Thu, 22 May 2014 15:39:58 +0200 Subject: [PATCH] PHP Fatal error when getContainer method of ContainerAwareCommand has be... --- .../FrameworkBundle/Command/ContainerAwareCommand.php | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/Symfony/Bundle/FrameworkBundle/Command/ContainerAwareCommand.php b/src/Symfony/Bundle/FrameworkBundle/Command/ContainerAwareCommand.php index 035f5536ee..2832479e3d 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Command/ContainerAwareCommand.php +++ b/src/Symfony/Bundle/FrameworkBundle/Command/ContainerAwareCommand.php @@ -29,11 +29,17 @@ abstract class ContainerAwareCommand extends Command implements ContainerAwareIn /** * @return ContainerInterface + * @throws \LogicException */ protected function getContainer() { if (null === $this->container) { - $this->container = $this->getApplication()->getKernel()->getContainer(); + $application = $this->getApplication(); + if (null === $application) { + throw new \LogicException('The container cannot be retrieved as the application instance is not yet set.'); + } + + $this->container = $application->getKernel()->getContainer(); } return $this->container;