src/GraphQL/EventListener/LoggingSubscriber.php line 30

Open in your IDE?
  1. <?php
  2. namespace GraphQL\EventListener;
  3. use App\Service\RequestLogManager;
  4. use Symfony\Component\EventDispatcher\EventSubscriberInterface;
  5. use Symfony\Component\HttpKernel\Event\ResponseEvent;
  6. use Symfony\Component\HttpKernel\KernelEvents;
  7. class LoggingSubscriber implements EventSubscriberInterface
  8. {
  9.     private RequestLogManager $requestLogManager;
  10.     public function __construct(RequestLogManager $requestLogManager)
  11.     {
  12.         $this->requestLogManager $requestLogManager;
  13.     }
  14.     public static function getSubscribedEvents(): array
  15.     {
  16.         return [
  17.             KernelEvents::RESPONSE => [
  18.                 ['logResponse'0]
  19.             ],
  20.         ];
  21.     }
  22.     public function logResponse(ResponseEvent $responseEvent): void
  23.     {
  24.         $this->requestLogManager->saveLog($responseEvent->getRequest(), $responseEvent->getResponse(), 'graphql');
  25.     }
  26. }