src/Core/Application/EventSubscriber/Chat/ChatUserDeactivatedSubscriber.php line 29
<?phpdeclare(strict_types=1);namespace App\Core\Application\EventSubscriber\Chat;use App\Core\Application\Event\Chat\ChatUserDeactivatedEvent;use App\Core\Application\Service\RocketChat\RocketChatClientServiceInterface;use App\Core\Domain\Entity\Student\Student;use App\Core\Domain\Entity\User\User;use Symfony\Component\EventDispatcher\EventSubscriberInterface;class ChatUserDeactivatedSubscriber implements EventSubscriberInterface{private readonly RocketChatClientServiceInterface $rocketChatClientService;public function __construct(RocketChatClientServiceInterface $rocketChatClientService){$this->rocketChatClientService = $rocketChatClientService;}public static function getSubscribedEvents(): array{return [ChatUserDeactivatedEvent::class => 'deactivateUser',];}public function deactivateUser(ChatUserDeactivatedEvent $event): void{$user = $event->user;if ($user instanceof Student) {$chatUserId = $user->getChatSetting()->getChatUserId();} elseif ($user instanceof User) {$chatUserId = $user->getChatSetting()->getChatUserId();} else {throw new \InvalidArgumentException('Invalid user object provided.');}$this->rocketChatClientService->setDeactivationUser($chatUserId);}}