69 if (!is_a(
$handler, NotificationEventHandler::class,
true)) {
73 if (!isset($this->events[$type])) {
74 $this->events[
$type] = [];
77 if (!isset($this->events[$type][$subtype])) {
81 if (empty(
$actions) && !array_key_exists(
'create', $this->events[$type][$subtype])) {
103 unset($this->events[$type][$subtype]);
107 unset($this->events[$type][$subtype][$action]);
110 if (empty($this->events[$type][$subtype])) {
111 unset($this->events[$type][$subtype]);
114 if (empty($this->events[$type])) {
115 unset($this->events[$type]);
130 return isset($this->events[$type][$subtype][$action]);
167 unset($this->methods[$name]);
188 return in_array($method, $this->methods);
201 $object_type = $object->
getType();
206 $actor = $object->getOwnerEntity() ?: null;
216 $registered = (bool) $this->elgg_events->triggerResults(
'enqueue',
'notification',
$params, $registered);
223 $this->elgg_events->trigger(
'enqueue',
'notifications', $object);
236 $handler = NotificationEventHandler::class;
256 $delivery_matrix = [];
260 while (time() < $stopTime) {
262 $event = $this->queue->dequeue();
275 $this->elgg_events->trigger(
'dequeue',
'notifications', $event->getObject());
280 $delivery_matrix[$event->getDescription()] =
$handler->send();
282 }
catch (\Throwable $t) {
287 return $matrix ? $delivery_matrix :
$count;
328 if (empty($this->methods)) {
332 $params[
'recipients'] = array_filter($recipients,
function($e) {
elgg_call(int $flags, Closure $closure)
Calls a callable autowiring the arguments using public DI services and applying logic based on flags...
getObject()
Get the object of the event.
isRegisteredEvent(string $type, string $subtype, string $action)
Check if a notification event is registered.
Exception thrown if an argument is not of the expected type.
$params
Saves global plugin settings.
if(!$user||!$user->canDelete()) $name
getType()
Return the type of the object - eg.
unregisterEvent(string $type, string $subtype, array $actions=[])
Unregister a notification event.
enqueueEvent(string $action,\ElggData $object,\ElggEntity $actor=null)
Add a notification event to the queue.
c Accompany it with the information you received as to the offer to distribute corresponding source complete source code means all the source code for all modules it plus any associated interface definition plus the scripts used to control compilation and installation of the executable as a special the source code distributed need not include anything that is normally and so on of the operating system on which the executable unless that component itself accompanies the executable If distribution of executable or object code is made by offering access to copy from a designated then offering equivalent access to copy the source code from the same place counts as distribution of the source even though third parties are not compelled to copy the source along with the object code You may not or distribute the Program except as expressly provided under this License Any attempt otherwise to sublicense or distribute the Program is void
getNotificationHandler(NotificationEvent $event)
Returns notification event handler based on event.
getAction()
Get the name of the action.
registerMethod(string $name)
Register a delivery method for notifications.
Notification Event Handler for instant notifications.
getSubtype()
Return a subtype.
Subscription notification event.
registerEvent(string $type, string $subtype, array $actions=[], string $handler=NotificationEventHandler::class)
Register a notification event.
elgg_extract($key, $array, $default=null, bool $strict=true)
Checks for $array[$key] and returns its value if it exists, else returns $default.
unregisterMethod(string $name)
Unregister a delivery method for notifications.
trait Loggable
Enables adding a logger.
Notification Event Handler handles preparation of a notification.
const ELGG_IGNORE_ACCESS
elgg_call() flags
__construct(Queue $queue,\ElggSession $session, EventsService $elgg_events)
Constructor.
Instant notification event.
getEvents()
Return the notification events.
if(!$menu instanceof\Elgg\Menu\PreparedMenu) $actions
getMethods()
Returns registered delivery methods for notifications.
A generic class that contains shared code among , , and .
sendInstantNotifications(\ElggEntity $sender, array $recipients=[], array $params=[])
Notify a user via their preferences.
getLogger()
Returns logger.
if($email instanceof\Elgg\Email) $object
Notification event interface.
isRegisteredMethod(string $method)
Check if a notification method is registed.
elgg_get_logged_in_user_entity()
Return the current logged in user, or null if no user is logged in.
processQueue($stopTime, $matrix=false)
Pull notification events from queue until stop time is reached.