custom/plugins/SwagCommercial/src/Licensing/Subscriber/AdminLicenseListener.php line 13

Open in your IDE?
  1. <?php declare(strict_types=1);
  2. namespace Shopware\Commercial\Licensing\Subscriber;
  3. use Shopware\Commercial\Licensing\License;
  4. use Symfony\Component\HttpKernel\Event\ResponseEvent;
  5. /**
  6.  * @internal
  7.  */
  8. final class AdminLicenseListener
  9. {
  10.     public function __invoke(ResponseEvent $event): void
  11.     {
  12.         if ($event->getRequest()->attributes->get('_route') !== 'api.info.config') {
  13.             return;
  14.         }
  15.         /** @var array{'version': string} $json */
  16.         $json json_decode((string) $event->getResponse()->getContent(), true512\JSON_THROW_ON_ERROR);
  17.         $json['licenseToggles'] = License::all();
  18.         $event->getResponse()->setContent(json_encode($json\JSON_THROW_ON_ERROR));
  19.     }
  20. }