vendor/shopware/core/Framework/Store/Subscriber/LicenseHostChangedSubscriber.php line 35

Open in your IDE?
  1. <?php declare(strict_types=1);
  2. namespace Shopware\Core\Framework\Store\Subscriber;
  3. use Doctrine\DBAL\Connection;
  4. use Shopware\Core\Framework\Store\Authentication\StoreRequestOptionsProvider;
  5. use Shopware\Core\System\SystemConfig\Event\SystemConfigChangedEvent;
  6. use Shopware\Core\System\SystemConfig\SystemConfigService;
  7. use Symfony\Component\EventDispatcher\EventSubscriberInterface;
  8. /**
  9.  * @internal
  10.  */
  11. class LicenseHostChangedSubscriber implements EventSubscriberInterface
  12. {
  13.     private SystemConfigService $systemConfigService;
  14.     private Connection $connection;
  15.     public function __construct(
  16.         SystemConfigService $systemConfigService,
  17.         Connection $connection
  18.     ) {
  19.         $this->systemConfigService $systemConfigService;
  20.         $this->connection $connection;
  21.     }
  22.     public static function getSubscribedEvents(): array
  23.     {
  24.         return [
  25.             SystemConfigChangedEvent::class => 'onLicenseHostChanged',
  26.         ];
  27.     }
  28.     public function onLicenseHostChanged(SystemConfigChangedEvent $event): void
  29.     {
  30.         if ($event->getKey() !== StoreRequestOptionsProvider::CONFIG_KEY_STORE_LICENSE_DOMAIN) {
  31.             return;
  32.         }
  33.         // The shop secret is unique for each license host and thus cannot remain the same
  34.         $this->systemConfigService->delete(StoreRequestOptionsProvider::CONFIG_KEY_STORE_SHOP_SECRET);
  35.         // Log out all users to enforce re-authentication
  36.         $this->connection->executeStatement('UPDATE user SET store_token = NULL');
  37.     }
  38. }