<?php
namespace App\EventSubscriber;
use App\Messenger\Message\ChannelUserDataMessage;
use Nellapp\Bundle\SDKBundle\Permission\Event\ChannelMenuDisplayedEvent;
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
use Symfony\Component\Messenger\MessageBusInterface;
class ChannelMenuDisplayedSubscriber implements EventSubscriberInterface
{
public function __construct(
private MessageBusInterface $bus,
)
{
}
public static function getSubscribedEvents(): array
{
return [
ChannelMenuDisplayedEvent::class => '__invoke',
];
}
public function __invoke(ChannelMenuDisplayedEvent $event): void
{
$this->bus->dispatch(new ChannelUserDataMessage($event)); //send message to avoid infinite loop in doctrine => Async process
}
}