<?php
declare(strict_types=1);
namespace Bodymed\Webshop\Core\Subscriber;
use Bodymed\Webshop\Core\Content\BodymedCenter\BodymedCenterEntity;
use Shopware\Core\Framework\DataAbstractionLayer\EntityRepositoryInterface;
use Shopware\Core\Framework\DataAbstractionLayer\Event\EntityLoadedEvent;
use Shopware\Core\Framework\DataAbstractionLayer\Search\Criteria;
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
class BodymedCenterSubscriber implements EventSubscriberInterface
{
private EntityRepositoryInterface $tagRepository;
public function __construct(EntityRepositoryInterface $tagRepository)
{
$this->tagRepository = $tagRepository;
}
public static function getSubscribedEvents(): array
{
return [
'bodymed_center.loaded' => 'onEntityLoaded',
];
}
public function onEntityLoaded(EntityLoadedEvent $event): void
{
/* @var $bodymedCenter BodymedCenterEntity */
/*foreach ($event->getEntities() as $bodymedCenter) {
if ($bodymedCenter->getMykeyConceptTagIds() !== null
&& $bodymedCenter->getMykeyConceptTags() === null
) {
$tags = $this->tagRepository->search(
new Criteria($bodymedCenter->getMykeyConceptTagIds()),
$event->getContext()
);
if ($tags->count() > 0) {
$bodymedCenter->setMykeyConceptTags($tags->getEntities());
}
}
}*/
}
}