src/Core/Application/EventSubscriber/Chat/KickUserOutOfChannelSubscriber.php line 35
<?phpdeclare(strict_types=1);namespace App\Core\Application\EventSubscriber\Chat;use App\Core\Application\Event\Chat\KickUserOutOfChannelEvent;use App\Core\Application\Service\RocketChat\RocketChatClientServiceInterface;use App\Core\Domain\Entity\ChatSetting\ChatChannel;use App\Core\Domain\Entity\Student\Student;use Doctrine\ORM\EntityManagerInterface;use Symfony\Component\EventDispatcher\EventSubscriberInterface;class KickUserOutOfChannelSubscriber implements EventSubscriberInterface{private readonly RocketChatClientServiceInterface $rocketChatClientService;private readonly EntityManagerInterface $em;public function __construct(EntityManagerInterface $em,RocketChatClientServiceInterface $rocketChatClientService,) {$this->rocketChatClientService = $rocketChatClientService;$this->em = $em;}public static function getSubscribedEvents(): array{return [KickUserOutOfChannelEvent::class => 'kickUserOfChannel',];}public function kickUserOfChannel(KickUserOutOfChannelEvent $event): void{$user = $event->user;if ($user instanceof Student) {$channels = $user->getChatSetting()->getChatChannels();/* @var ChatChannel $channel */foreach ($channels as $channel) {/** @TODO Add logic that will retrieve the information about the completed subscription for the course and pass the channel */$this->rocketChatClientService->kickUserOurOfChannel($channel->getChatChannelId(), $user->getChatSetting()->getChatUserId());}}}}