46 final public function send(): array {
59 $params[
'deliveries'] = $deliveries;
76 'methods_override' => (array)
elgg_extract(
'methods_override', $this->params, []),
90 return (
bool)
elgg_extract(
'apply_muting', $this->params,
true);
108 $object = $this->
event->getObject();
115 $exclude[] =
$object->owner_guid;
119 $exclude[] =
$object->container_guid;
165 return $this->service->getMethods();
197 if ($this->service->isRegisteredMethod($method)) {
203 _elgg_services()->logger->info(
"Results for the notification event {$this->event->getDescription()}: " . print_r(
$result,
true));
217 if (!
_elgg_services()->events->hasHandler(
'send',
"notification:{$method}")) {
222 $actor = $this->
event->getActor();
223 $object = $this->
event->getObject();
265 $params[
'action'] = $this->
event->getAction();
291 $logger_data = print_r((array) $notification->
toObject(),
true);
293 _elgg_services()->logger->info(
'Notification sent: ' . $logger_data);
295 _elgg_services()->logger->info(
'Notification was not sent: ' . $logger_data);
311 $notification =
new Notification($params[
'sender'], $params[
'recipient'], $params[
'language'], $params[
'subject'], $params[
'body'], $params[
'summary'], $params);
315 throw new RuntimeException(
"'prepare','notification' event must return an instance of " . Notification::class);
318 $type =
'notification:' . $this->
event->getDescription();
321 throw new RuntimeException(
"'prepare','{$type}' event must return an instance of " . Notification::class);
331 throw new RuntimeException(
"'format','notification:{$params['method']}' event must return an instance of " . Notification::class);
349 $actor = $this->
event->getActor();
350 $object = $this->
event->getObject();
355 $subject_key =
"notification:{$this->event->getDescription()}:subject";
395 $actor = $this->
event->getActor();
396 $object = $this->
event->getObject();
401 $body_key =
"notification:{$this->event->getDescription()}:body";
405 $container_name =
'';
408 $container_name =
$container->getDisplayName();
412 $container_name =
'';
449 $object = $this->
event->getObject();
476 return static::isConfigurableForUser($entity);
478 return static::isConfigurableForGroup($entity);
static isConfigurableByUser()
Is this event configurable by the user on the notification settings page.
static isConfigurableForEntity(\ElggEntity $entity)
Can this event be configured for a specific entity.
if(!elgg_get_config('trash_enabled')) $group
toObject()
Export notification.
prepareSubscriptions()
Returns subscriptions.
Exception thrown if an error which can only be found on runtime occurs.
static isConfigurableForUser(\ElggUser $user)
Can this event be configured for a specific user.
prepareNotification(array $params)
Prepares a notification for delivery.
excludeOwnerSubscribers()
Exclude the NotificationEvent object owner_guid when fetching the subscription records for this notif...
getMethods()
Returns methods to be used for this notification.
getNotificationURL(\ElggUser $recipient, string $method)
Returns the url related to this notification.
getNotificationSubject(\ElggUser $recipient, string $method)
Get subject for the notification.
sendNotification(int $guid, string $method, array $params=[])
Send a notification to a subscriber.
getSubscriptions()
Returns subscriptions for the event.
if($item instanceof\ElggEntity) elseif($item instanceof\ElggRiverItem) elseif($item instanceof\ElggRelationship) elseif(is_callable([$item, 'getType']))
elgg_extract($key, $array, $default=null, bool $strict=true)
Checks for $array[$key] and returns its value if it exists, else returns $default.
sendNotifications($subscriptions, array $params=[])
Sends the notifications based on subscriptions.
Notification Event Handler handles preparation of a notification.
deliverNotification(Notification $notification, string $method)
Deliver a notification.
filterMutedSubscriptions()
Should muted subscribers be filtered.
excludeContainerSubscribers()
Exclude the NotificationEvent object container_guid when fetching the subscription records for this n...
getLanguage(string $fallback=null)
Get user language or default to site language.
Instant notification event.
addMuteLink()
Add a mute link in the email notification.
getNotificationBody(\ElggUser $recipient, string $method)
Get body for the notification.
getNotificationSubsciptionExclusionGUIDs()
Get an array of GUIDs to not get the subscription records for.
if($email instanceof\Elgg\Email) $object
getNotificationSummary(\ElggUser $recipient, string $method)
Return the summary for a notification.
Notification event interface.
excludeEntitySubscribers()
Exclude the NotificationEvent object guid when fetching the subscription records for this notificatio...
if(!$owner instanceof ElggEntity) $summary
_elgg_services()
Get the global service provider.
static isConfigurableForGroup(\ElggGroup $group)
Can this event be configured for a specific group.
if(!$new_container instanceof\ElggEntity) if(!$new_container->canWriteToContainer(0, $entity->type, $entity->subtype)) $display_name
if(empty($methods)) $subscriptions
_elgg_view_under_viewtype(string $view, array $vars, string $viewtype)
Render a view while the global viewtype is temporarily changed.
elgg_view_exists(string $view, string $viewtype= '', bool $recurse=true)
Returns whether the specified view exists.
__construct(NotificationEvent $event, NotificationsService $service, array $params=[])
Constructor.
getDisplayName()
Get the entity's display name.
$guid
Reset an ElggUpgrade.