vendor/synergybot/innerapi-bundle/EventListener/InnerApiTokenListener.php line 32

Open in your IDE?
  1. <?php
  2. declare(strict_types=1);
  3. /*
  4.  * This file is part of the SynergyBot project.
  5.  *
  6.  * For the full copyright and license information,
  7.  * please read the LICENSE.md file that was distributed with this source code.
  8.  *
  9.  * The SymfonyBot project - inspiring people to chat!
  10.  *
  11.  * Copyright (c) 2022.
  12.  */
  13. namespace SynergyBot\InnerApiBundle\EventListener;
  14. use Symfony\Component\HttpKernel\Event\RequestEvent;
  15. use SynergyBot\InnerApiBundle\Service\TokenService;
  16. class InnerApiTokenListener
  17. {
  18.     private const ROUTE '/innerapi';
  19.     private TokenService $tokenService;
  20.     public function __construct(TokenService $tokenService)
  21.     {
  22.         $this->tokenService $tokenService;
  23.     }
  24.     public function onKernelRequest(RequestEvent $event)
  25.     {
  26.         if (!$event->isMainRequest()) {
  27.             return;
  28.         }
  29.         $request $event->getRequest();
  30.         if (!str_starts_with($request->getPathInfo(), self::ROUTE)) {
  31.             return;
  32.         }
  33.         $this->tokenService->checkRequest($request);
  34.     }
  35. }