custom/plugins/SwagCommercial/src/Licensing/Subscriber/LicenseReportListener.php line 24

Open in your IDE?
  1. <?php declare(strict_types=1);
  2. namespace Shopware\Commercial\Licensing\Subscriber;
  3. use Shopware\Commercial\Licensing\LicenseReporter;
  4. use Symfony\Component\HttpFoundation\Response;
  5. use Symfony\Component\HttpKernel\Event\RequestEvent;
  6. /**
  7.  * @internal
  8.  */
  9. final class LicenseReportListener
  10. {
  11.     private LicenseReporter $reporter;
  12.     /**
  13.      * @internal
  14.      */
  15.     public function __construct(LicenseReporter $reporter)
  16.     {
  17.         $this->reporter $reporter;
  18.     }
  19.     public function __invoke(RequestEvent $event): void
  20.     {
  21.         $request $event->getRequest();
  22.         if ($request->headers->has('sw-license-toggle')) {
  23.             $this->reporter->reportNow((string) $request->headers->get('sw-license-toggle'));
  24.             $event->setResponse(new Response(''Response::HTTP_NO_CONTENT));
  25.         }
  26.         if ($request->attributes->get('_route') !== 'api.action.store.plugin.search') {
  27.             return;
  28.         }
  29.         $this->reporter->report();
  30.     }
  31. }