 
  
   
  
  PHP Warning: unserialize() expects parameter 1 to be string, object given in /home/3g9zap/prog.php on line 5
 
  
   
  
   
  
  class UserRegistered extends Event
{
    public const NAME = 'user.registered';
    protected $user;
    public function __construct(User $user)
    {
        $this-> user = $user;
    }
    public function getUser()
    {
        return $this->user;
    }
}use Symfony\Component\EventDispatcher\EventDispatcher;
$dispatcher = new EventDispatcher();
$user = new User();
$event = new UserRegistered($user);
$dispatcher->dispatch($event, UserRegistered::NAME);class NotificationMessage
{
    private $content;
    private $type;
    private $subject;
    public function __construct(string $type, $subject, string $content)
    {
        $this->type = $type;
        $this->content = $content;
        $this->subject = $subject;
    }
    public function getType(): string
    {
        return $this->type;
    }
    public function getSubject(): string
    {
        return $this->subject;
    }
    public function getContent(): string
    {
        return $this->content;
    }
}class NotificationSubscriber implements EventSubscriberInterface
{
    private $twig;
    private $bus;
    public function __construct(Environment $twig, MessageBusInterface $bus)
    {
        $this->twig = $twig;
        $this->bus = $bus;
    }
    public static function getSubscribedEvents()
    {
        return [
            UserRegistered::NAME => 'onNotification',
        ];
    }
    public function onNotification(UserRegistered $event)
    {
        $notification = new NotificationMessage(
            UserRegistered::NAME,
            sprintf('Пользователь %s зарегистрирован', $event->getUser()->getName()),
            $this->twig->render('notification/user-created.twig')//Шаблон User Created
        );
        $this->bus->dispatch($notification);
    }
}use App\Model\Notification\Entity\Subscriber\SubscriberRepository;
use App\Model\Notification\Entity\Subscriber\Subscriber;
use Symfony\Component\Notifier\Notification\Notification;
use Symfony\Component\Notifier\NotifierInterface;
use Symfony\Component\Notifier\Recipient\Recipient;
use Twig\Environment;
class NotificationHandler implements MessageHandlerInterface
{
    private $subscribers;
    private $notifier;
    private $texter;
    public function __construct(SubscriberRepository $subscribers, NotifierInterface $notifier, TexterInterface $texter)
    {
        $this->subscribers = $subscribers;
        $this->notifier = $notifier;
        $this->texter = $texter;
    }
    public function __invoke(NotificationMessage $message)
    {
        /** @var Subscriber[] $subscribers */
        $subscribers = $this->subscribers->getAllActiveForType($message->getType());
        foreach ($subscribers as $subscriber) {
            foreach ($subscriber->getChannels() as $channel) {
                if ($channel->isForChannel('email')) {
                    $notification = (new Notification($message->getSubject()))
                        ->content('You got a new invoice for 15 EUR.');
                    // The receiver of the Notification
                    $recipient = new Recipient(
                        $subscriber->getEmail(),
                        $subscriber->getPhone()
                    );
                    // Send the notification to the recipient
                    $this->notifier->send($notification, $recipient);
                }
                if ($channel->isForChannel('sms')) {
                    $sms = new SmsMessage(
                        $subscriber->getPhone(),
                        $message->getContent()
                    );
                    $this->texter->send($sms);
                }
                if ($channel->isForChannel('service')) {
                    $service = new ServiceMessage(
                        $recipient,
                        $message->getSubject(),
                        $message->getContent()
                    );
                    $this->servicer->send($service);
                }
            }
        }
    }
} 
  
   
  
   
  
   
  
   
  
  mysql> show grants for admin_root@localhost;
+-------------------------------------------------------------------------------------+
| Grants for admin_root@localhost                                                     |
+-------------------------------------------------------------------------------------+
| GRANT USAGE ON *.* TO 'admin_root'@'localhost'                                      |
| GRANT ALL PRIVILEGES ON `main_data`.* TO 'admin_root'@'localhost' WITH GRANT OPTION |
+-------------------------------------------------------------------------------------+
2 rows in set (0.00 sec) 
  
  У одного События - может быть куча мероприятий (events)Не понял немного в терминологии. Events это разве не событие и не мероприятие? Просто оно переводится примерно одинаково...
К event привязывается hall, дата, событие