AzuraCast/src/Event/GetNotifications.php

56 lines
1.1 KiB
PHP

<?php
namespace App\Event;
use App\Entity\User;
use App\Notification\Notification;
use Symfony\Component\EventDispatcher\Event;
class GetNotifications extends Event
{
public const NAME = 'get-notifications';
/** @var User */
protected $current_user;
/** @var array */
protected $notifications;
/**
* GetNotifications constructor.
* @param User $current_user
*/
public function __construct(User $current_user)
{
$this->current_user = $current_user;
$this->notifications = [];
}
/**
* @return User
*/
public function getCurrentUser(): User
{
return $this->current_user;
}
/**
* Add a new notification to the list that will be displayed.
*
* @param Notification $notification
*/
public function addNotification(Notification $notification)
{
$this->notifications[] = $notification;
}
/**
* Retrieve the complete list of notifications that were triggered.
*
* @return Notification[]
*/
public function getNotifications(): array
{
return $this->notifications;
}
}