vendor/api-platform/core/src/Symfony/Bundle/EventListener/SwaggerUiListener.php line 23

Open in your IDE?
  1. <?php
  2. /*
  3.  * This file is part of the API Platform project.
  4.  *
  5.  * (c) Kévin Dunglas <dunglas@gmail.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. declare(strict_types=1);
  11. namespace ApiPlatform\Symfony\Bundle\EventListener;
  12. use Symfony\Component\HttpKernel\Event\RequestEvent;
  13. final class SwaggerUiListener
  14. {
  15.     /**
  16.      * Sets SwaggerUiAction as controller if the requested format is HTML.
  17.      */
  18.     public function onKernelRequest(RequestEvent $event): void
  19.     {
  20.         $request $event->getRequest();
  21.         if (
  22.             'html' !== $request->getRequestFormat('') ||
  23.             !($request->attributes->has('_api_resource_class') || $request->attributes->getBoolean('_api_respond'false))
  24.         ) {
  25.             return;
  26.         }
  27.         $request->attributes->set('_controller''api_platform.swagger.action.ui');
  28.     }
  29. }
  30. class_alias(SwaggerUiListener::class, \ApiPlatform\Core\Bridge\Symfony\Bundle\EventListener\SwaggerUiListener::class);