vendor/symfony/swiftmailer-bundle/Command/AbstractSwiftMailerCommand.php line 27

Open in your IDE?
  1. <?php
  2. /*
  3.  * This file is part of the Symfony package.
  4.  *
  5.  * (c) Fabien Potencier <fabien@symfony.com>
  6.  *
  7.  * For the full copyright and license information, please view the LICENSE
  8.  * file that was distributed with this source code.
  9.  */
  10. namespace Symfony\Bundle\SwiftmailerBundle\Command;
  11. use Symfony\Component\Console\Command\Command;
  12. use Symfony\Component\DependencyInjection\ContainerInterface;
  13. /**
  14.  * @internal
  15.  */
  16. abstract class AbstractSwiftMailerCommand extends Command
  17. {
  18.     /**
  19.      * @var ContainerInterface|null
  20.      */
  21.     private $container;
  22.     public function setContainer(ContainerInterface $container null)
  23.     {
  24.         $this->container $container;
  25.     }
  26.     /**
  27.      * @return ContainerInterface
  28.      *
  29.      * @throws \LogicException
  30.      */
  31.     protected function getContainer()
  32.     {
  33.         if (null === $this->container) {
  34.             $application $this->getApplication();
  35.             if (null === $application) {
  36.                 throw new \LogicException('The container cannot be retrieved as the application instance is not yet set.');
  37.             }
  38.             $this->container $application->getKernel()->getContainer();
  39.         }
  40.         return $this->container;
  41.     }
  42. }