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

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 Symfony\Component\EventDispatcher\EventSubscriberInterface;
  6. /**
  7.  * @internal
  8.  */
  9. class AppScriptConditionConstraintsSubscriber implements EventSubscriberInterface
  10. {
  11.     public static function getSubscribedEvents(): array
  12.     {
  13.         return [
  14.             'app_script_condition.loaded' => 'unserialize',
  15.         ];
  16.     }
  17.     public function unserialize(EntityLoadedEvent $event): void
  18.     {
  19.         /** @var AppScriptConditionEntity $entity */
  20.         foreach ($event->getEntities() as $entity) {
  21.             $constraints $entity->getConstraints();
  22.             if ($constraints === null || !\is_string($constraints)) {
  23.                 continue;
  24.             }
  25.             $entity->setConstraints(unserialize($constraints));
  26.         }
  27.     }
  28. }