src/Core/Subscriber/BodymedCenterSubscriber.php line 29

Open in your IDE?
  1. <?php
  2. declare(strict_types=1);
  3. namespace Bodymed\Webshop\Core\Subscriber;
  4. use Bodymed\Webshop\Core\Content\BodymedCenter\BodymedCenterEntity;
  5. use Shopware\Core\Framework\DataAbstractionLayer\EntityRepositoryInterface;
  6. use Shopware\Core\Framework\DataAbstractionLayer\Event\EntityLoadedEvent;
  7. use Shopware\Core\Framework\DataAbstractionLayer\Search\Criteria;
  8. use Symfony\Component\EventDispatcher\EventSubscriberInterface;
  9. class BodymedCenterSubscriber implements EventSubscriberInterface
  10. {
  11.     private EntityRepositoryInterface $tagRepository;
  12.     public function __construct(EntityRepositoryInterface $tagRepository)
  13.     {
  14.         $this->tagRepository $tagRepository;
  15.     }
  16.     public static function getSubscribedEvents(): array
  17.     {
  18.         return [
  19.             'bodymed_center.loaded' => 'onEntityLoaded',
  20.         ];
  21.     }
  22.     public function onEntityLoaded(EntityLoadedEvent $event): void
  23.     {
  24.         /* @var $bodymedCenter BodymedCenterEntity */
  25.         /*foreach ($event->getEntities() as $bodymedCenter) {
  26.             if ($bodymedCenter->getMykeyConceptTagIds() !== null
  27.                 && $bodymedCenter->getMykeyConceptTags() === null
  28.             ) {
  29.                $tags = $this->tagRepository->search(
  30.                     new Criteria($bodymedCenter->getMykeyConceptTagIds()),
  31.                     $event->getContext()
  32.                 );
  33.                 if ($tags->count() > 0) {
  34.                     $bodymedCenter->setMykeyConceptTags($tags->getEntities());
  35.                 }
  36.             }
  37.         }*/
  38.     }
  39. }