vendor/shopware/core/Framework/App/Subscriber/AppScriptConditionConstraintsSubscriber.php line 23

Open in your IDE?
  1. <?php declare(strict_types=1);
  2. namespace Shopware\Core\Framework\App\Subscriber;
  3. use Shopware\Core\Framework\App\Aggregate\AppScriptCondition\AppScriptConditionEntity;
  4. use Shopware\Core\Framework\DataAbstractionLayer\Event\EntityLoadedEvent;
  5. use Shopware\Core\Framework\Log\Package;
  6. use Symfony\Component\EventDispatcher\EventSubscriberInterface;
  7. /**
  8.  * @internal
  9.  */
  10. #[Package('core')]
  11. class AppScriptConditionConstraintsSubscriber implements EventSubscriberInterface
  12. {
  13.     public static function getSubscribedEvents(): array
  14.     {
  15.         return [
  16.             'app_script_condition.loaded' => 'unserialize',
  17.         ];
  18.     }
  19.     public function unserialize(EntityLoadedEvent $event): void
  20.     {
  21.         /** @var AppScriptConditionEntity $entity */
  22.         foreach ($event->getEntities() as $entity) {
  23.             $constraints $entity->getConstraints();
  24.             if ($constraints === null || !\is_string($constraints)) {
  25.                 continue;
  26.             }
  27.             $entity->setConstraints(unserialize($constraints));
  28.         }
  29.     }
  30. }