custom/plugins/NetiNextCmsElementBuilder/src/Subscriber/ElementLoadSubscriber.php line 20

Open in your IDE?
  1. <?php
  2. declare(strict_types=1);
  3. namespace NetInventors\NetiNextCmsElementBuilder\Subscriber;
  4. use NetInventors\NetiNextCmsElementBuilder\Core\Content\Element\ElementEntity;
  5. use Shopware\Core\Framework\DataAbstractionLayer\Event\EntityLoadedEvent;
  6. use Symfony\Component\EventDispatcher\EventSubscriberInterface;
  7. class ElementLoadSubscriber implements EventSubscriberInterface
  8. {
  9.     public static function getSubscribedEvents(): array
  10.     {
  11.         return [
  12.             'neti_ceb_element.loaded' => 'onLoad',
  13.         ];
  14.     }
  15.     public function onLoad(EntityLoadedEvent $event): void
  16.     {
  17.         /** @var ElementEntity $entity */
  18.         foreach ($event->getEntities() as $entity) {
  19.             $entity->setSlotName(
  20.                 str_replace('_''-'$entity->getName())
  21.             );
  22.         }
  23.     }
  24. }