core/lib/Thelia/Core/TheliaHttpKernel.php line 68

  1. <?php
  2. /*
  3.  * This file is part of the Thelia package.
  4.  * http://www.thelia.net
  5.  *
  6.  * (c) OpenStudio <info@thelia.net>
  7.  *
  8.  * For the full copyright and license information, please view the LICENSE
  9.  * file that was distributed with this source code.
  10.  */
  11. namespace Thelia\Core;
  12. use Symfony\Component\DependencyInjection\ContainerInterface;
  13. use Symfony\Component\EventDispatcher\EventDispatcherInterface;
  14. use Symfony\Component\HttpFoundation\Request;
  15. use Symfony\Component\HttpFoundation\RequestStack;
  16. use Symfony\Component\HttpKernel\Controller\ArgumentResolverInterface;
  17. use Symfony\Component\HttpKernel\Controller\ControllerResolverInterface;
  18. use Symfony\Component\HttpKernel\HttpKernel;
  19. use Symfony\Component\HttpKernel\HttpKernelInterface;
  20. use Thelia\Core\HttpFoundation\Response;
  21. /**
  22.  * @author Manuel Raynaud <manu@raynaud.io>
  23.  */
  24. class TheliaHttpKernel extends HttpKernel
  25. {
  26.     protected static $session;
  27.     protected $container;
  28.     public function __construct(
  29.         EventDispatcherInterface $dispatcher,
  30.         ContainerInterface $container,
  31.         ControllerResolverInterface $controllerResolver,
  32.         RequestStack $requestStack,
  33.         ArgumentResolverInterface $argumentResolver
  34.     ) {
  35.         parent::__construct($dispatcher$controllerResolver$requestStack$argumentResolver);
  36.         $container->get('thelia.url.manager');
  37.         $this->container $container;
  38.     }
  39.     public function getContainer()
  40.     {
  41.         return $this->container;
  42.     }
  43.     /**
  44.      * Handles a Request to convert it to a Response.
  45.      *
  46.      * When $catch is true, the implementation must catch all exceptions
  47.      * and do its best to convert them to a Response instance.
  48.      *
  49.      * @param Request $request A Request instance
  50.      * @param int     $type    The type of the request
  51.      *                         (one of HttpKernelInterface::MASTER_REQUEST or HttpKernelInterface::SUB_REQUEST)
  52.      * @param bool    $catch   Whether to catch exceptions or not
  53.      *
  54.      * @throws \Exception When an Exception occurs during processing
  55.      *
  56.      * @return Response A Response instance
  57.      *
  58.      * @api
  59.      */
  60.     public function handle(Request $request$type HttpKernelInterface::MAIN_REQUEST$catch true): \Symfony\Component\HttpFoundation\Response
  61.     {
  62.         $this->container->get('request.context')->fromRequest($request);
  63.         $response parent::handle($request$type$catch);
  64.         return $response;
  65.     }
  66. }