<?php
declare(strict_types=1);
namespace App\EventsSubscriber\Creator;
use App\Event\Creator\BannedEvent;
use App\Services\Activity\ActivityServiceInterface;
use App\Services\Payment\PriceService;
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
use Symfony\Component\Messenger\MessageBusInterface;
class CreatorEventSubscriber implements EventSubscriberInterface
{
public static function getSubscribedEvents(): array
{
return [
BannedEvent::class => 'onBanned',
];
}
public function __construct(
private readonly PriceService $priceService,
private readonly MessageBusInterface $bus,
private readonly ActivityServiceInterface $activityService,
) {}
public function onBanned(BannedEvent $event): void
{
$creator = $event->getCreator();
$this->activityService->declineAllActivitiesByCreator($creator->getId(), "You are banned. Contact support");
}
}