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;