[ Index ]

PHP Cross Reference of phpBB-3.1.12-deutsch

title

Body

[close]

/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/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\HttpFoundation\Request;
  15  use Symfony\Component\HttpKernel\HttpKernelInterface;
  16  use Symfony\Component\HttpKernel\HttpKernel;
  17  use Symfony\Component\HttpKernel\Controller\ControllerResolverInterface;
  18  use Symfony\Component\EventDispatcher\EventDispatcherInterface;
  19  use Symfony\Component\DependencyInjection\ContainerInterface;
  20  use Symfony\Component\DependencyInjection\Scope;
  21  
  22  /**
  23   * Adds a managed request scope.
  24   *
  25   * @author Fabien Potencier <fabien@symfony.com>
  26   * @author Johannes M. Schmitt <schmittjoh@gmail.com>
  27   */
  28  class ContainerAwareHttpKernel extends HttpKernel
  29  {
  30      protected $container;
  31  
  32      /**
  33       * Constructor.
  34       *
  35       * @param EventDispatcherInterface    $dispatcher         An EventDispatcherInterface instance
  36       * @param ContainerInterface          $container          A ContainerInterface instance
  37       * @param ControllerResolverInterface $controllerResolver A ControllerResolverInterface instance
  38       */
  39      public function __construct(EventDispatcherInterface $dispatcher, ContainerInterface $container, ControllerResolverInterface $controllerResolver)
  40      {
  41          parent::__construct($dispatcher, $controllerResolver);
  42  
  43          $this->container = $container;
  44  
  45          // the request scope might have been created before (see FrameworkBundle)
  46          if (!$container->hasScope('request')) {
  47              $container->addScope(new Scope('request'));
  48          }
  49      }
  50  
  51      /**
  52       * {@inheritdoc}
  53       */
  54      public function handle(Request $request, $type = HttpKernelInterface::MASTER_REQUEST, $catch = true)
  55      {
  56          $request->headers->set('X-Php-Ob-Level', ob_get_level());
  57  
  58          $this->container->enterScope('request');
  59          $this->container->set('request', $request, 'request');
  60  
  61          try {
  62              $response = parent::handle($request, $type, $catch);
  63          } catch (\Exception $e) {
  64              $this->container->set('request', null, 'request');
  65              $this->container->leaveScope('request');
  66  
  67              throw $e;
  68          } catch (\Throwable $e) {
  69              $this->container->set('request', null, 'request');
  70              $this->container->leaveScope('request');
  71  
  72              throw $e;
  73          }
  74  
  75          $this->container->set('request', null, 'request');
  76          $this->container->leaveScope('request');
  77  
  78          return $response;
  79      }
  80  }


Generated: Thu Jan 11 00:25:41 2018 Cross-referenced by PHPXref 0.7.1