src/FlexApp/Sentry/SentryFlushSubscriber.php line 31

Open in your IDE?
  1. <?php
  2. declare(strict_types=1);
  3. namespace FlexApp\Sentry;
  4. use Sentry\State\HubInterface;
  5. use Symfony\Component\Console\ConsoleEvents;
  6. use Symfony\Component\EventDispatcher\EventSubscriberInterface;
  7. use Symfony\Component\HttpKernel\KernelEvents;
  8. final class SentryFlushSubscriber implements EventSubscriberInterface
  9. {
  10.     /** @var HubInterface */
  11.     private $hub;
  12.     public function __construct(HubInterface $hub)
  13.     {
  14.         $this->hub $hub;
  15.     }
  16.     public static function getSubscribedEvents(): array
  17.     {
  18.         return [
  19.             KernelEvents::TERMINATE => ['flush', -1024],
  20.             ConsoleEvents::TERMINATE => ['flush', -1024],
  21.         ];
  22.     }
  23.     public function flush(): void
  24.     {
  25.         $client $this->hub->getClient();
  26.         if ($client !== null) {
  27.             $client->flush();
  28.         }
  29.     }
  30. }