[ Index ]

PHP Cross Reference of phpBB-3.2.11-deutsch

title

Body

[close]

/vendor/symfony/http-kernel/DependencyInjection/ -> ContainerAwareHttpKernel.php (source)

   1  <?php
   2  
   3  /*
   4   * This file is part of the Symfony package.
   5   *
   6   * (c) Fabien Potencier <fabien@symfony.com>
   7   *
   8   * For the full copyright and license information, please view the LICENSE
   9   * file that was distributed with this source code.
  10   */
  11  
  12  namespace Symfony\Component\HttpKernel\DependencyInjection;
  13  
  14  use Symfony\Component\DependencyInjection\ContainerInterface;
  15  use Symfony\Component\DependencyInjection\Scope;
  16  use Symfony\Component\EventDispatcher\EventDispatcherInterface;
  17  use Symfony\Component\HttpFoundation\Request;
  18  use Symfony\Component\HttpFoundation\RequestStack;
  19  use Symfony\Component\HttpKernel\Controller\ControllerResolverInterface;
  20  use Symfony\Component\HttpKernel\HttpKernel;
  21  use Symfony\Component\HttpKernel\HttpKernelInterface;
  22  
  23  /**
  24   * Adds a managed request scope.
  25   *
  26   * @author Fabien Potencier <fabien@symfony.com>
  27   * @author Johannes M. Schmitt <schmittjoh@gmail.com>
  28   *
  29   * @deprecated since version 2.7, to be removed in 3.0.
  30   */
  31  class ContainerAwareHttpKernel extends HttpKernel
  32  {
  33      protected $container;
  34  
  35      /**
  36       * @param EventDispatcherInterface    $dispatcher         An EventDispatcherInterface instance
  37       * @param ContainerInterface          $container          A ContainerInterface instance
  38       * @param ControllerResolverInterface $controllerResolver A ControllerResolverInterface instance
  39       * @param RequestStack                $requestStack       A stack for master/sub requests
  40       * @param bool                        $triggerDeprecation Whether or not to trigger the deprecation warning for the ContainerAwareHttpKernel
  41       */
  42      public function __construct(EventDispatcherInterface $dispatcher, ContainerInterface $container, ControllerResolverInterface $controllerResolver, RequestStack $requestStack = null, $triggerDeprecation = true)
  43      {
  44          parent::__construct($dispatcher, $controllerResolver, $requestStack);
  45  
  46          if ($triggerDeprecation) {
  47              @trigger_error('The '.__CLASS__.' class is deprecated since Symfony 2.7 and will be removed in 3.0. Use the Symfony\Component\HttpKernel\HttpKernel class instead.', E_USER_DEPRECATED);
  48          }
  49  
  50          $this->container = $container;
  51  
  52          // the request scope might have been created before (see FrameworkBundle)
  53          if (!$container->hasScope('request')) {
  54              $container->addScope(new Scope('request'));
  55          }
  56      }
  57  
  58      /**
  59       * {@inheritdoc}
  60       */
  61      public function handle(Request $request, $type = HttpKernelInterface::MASTER_REQUEST, $catch = true)
  62      {
  63          $this->container->enterScope('request');
  64          $this->container->set('request', $request, 'request');
  65  
  66          try {
  67              $response = parent::handle($request, $type, $catch);
  68          } catch (\Exception $e) {
  69              $this->container->set('request', null, 'request');
  70              $this->container->leaveScope('request');
  71  
  72              throw $e;
  73          } catch (\Throwable $e) {
  74              $this->container->set('request', null, 'request');
  75              $this->container->leaveScope('request');
  76  
  77              throw $e;
  78          }
  79  
  80          $this->container->set('request', null, 'request');
  81          $this->container->leaveScope('request');
  82  
  83          return $response;
  84      }
  85  }


Generated: Wed Nov 11 20:33:01 2020 Cross-referenced by PHPXref 0.7.1