Elgg  Version 6.3
Public Member Functions | Static Public Member Functions | Protected Member Functions | Static Protected Member Functions | Protected Attributes | List of all members
Elgg\Notifications\NotificationEventHandler Class Reference

Notification Event Handler handles preparation of a notification. More...

Inheritance diagram for Elgg\Notifications\NotificationEventHandler:
Elgg\Notifications\NonConfigurableNotificationEventHandler Elgg\Notifications\CreateCommentEventHandler Elgg\Notifications\Handlers\AdminValidation Elgg\Notifications\InstantNotificationEventHandler Elgg\Notifications\MakeAdminUserEventHandler Elgg\Notifications\MentionsEventHandler Elgg\Notifications\RemoveAdminUserEventHandler Elgg\Notifications\UnbanUserEventHandler Elgg\Notifications\Handlers\AddUser Elgg\Notifications\Handlers\BanUser Elgg\Notifications\Handlers\ChangeUserPassword Elgg\Notifications\Handlers\ConfirmEmailChange Elgg\Notifications\Handlers\ConfirmPasswordChange Elgg\Notifications\Handlers\RequestUserPassword Elgg\Notifications\Handlers\ResetUserPassword Elgg\Notifications\Handlers\ValidateUser

Public Member Functions

 __construct (protected NotificationEvent $event, protected NotificationsService $service, array $params=[])
 Constructor. More...
 
 send ()
 Process the event. More...
 
 getSubscriptions ()
 Returns subscriptions for the event. More...
 
 getMethods ()
 Returns methods to be used for this notification. More...
 

Static Public Member Functions

static isConfigurableByUser ()
 Is this event configurable by the user on the notification settings page. More...
 
static isConfigurableForEntity (\ElggEntity $entity)
 Can this event be configured for a specific entity. More...
 

Protected Member Functions

 setMethodsOverride (array $methods)
 Override the default user preferred delivery methods with the given methods. More...
 
 getMethodsOverride ()
 Get the delivery methods override. More...
 
 getNotificationMethods ()
 Get the notification methods to use. More...
 
 prepareSubscriptions ()
 Returns subscriptions. More...
 
 filterMutedSubscriptions ()
 Should muted subscribers be filtered. More...
 
 getNotificationSubsciptionExclusionGUIDs ()
 Get an array of GUIDs to not get the subscription records for. More...
 
 excludeOwnerSubscribers ()
 Exclude the NotificationEvent object owner_guid when fetching the subscription records for this notification. More...
 
 excludeContainerSubscribers ()
 Exclude the NotificationEvent object container_guid when fetching the subscription records for this notification. More...
 
 excludeEntitySubscribers ()
 Exclude the NotificationEvent object guid when fetching the subscription records for this notification. More...
 
 sendNotifications (array $subscriptions, array $params=[])
 Sends the notifications based on subscriptions. More...
 
 sendNotification (\ElggEntity $recipient, string $method, array $params=[])
 Send a notification to a subscriber. More...
 
 deliverNotification (Notification $notification, string $method)
 Deliver a notification. More...
 
 prepareNotification (array $params)
 Prepares a notification for delivery. More...
 
 getNotificationSubject (\ElggUser $recipient, string $method)
 Get subject for the notification. More...
 
 getNotificationBody (\ElggUser $recipient, string $method)
 Get body for the notification. More...
 
 getNotificationSummary (\ElggUser $recipient, string $method)
 Return the summary for a notification. More...
 
 getNotificationURL (\ElggUser $recipient, string $method)
 Returns the url related to this notification. More...
 
 getNotificationAttachments (\ElggUser $recipient, string $method)
 Get the attachments for this notification. More...
 
 getEventActor ()
 Get the acting user from the notification event. More...
 
 getEventEntity ()
 Get the entity from the notification event. More...
 
 addMuteLink ()
 Add a mute link in the email notification. More...
 
 getParam (string $param, mixed $default=null)
 Get a parameter from the notification parameters. More...
 

Static Protected Member Functions

static isConfigurableForUser (\ElggUser $user)
 Can this event be configured for a specific user. More...
 
static isConfigurableForGroup (\ElggGroup $group)
 Can this event be configured for a specific group. More...
 

Protected Attributes

array $params = []
 
array $methods_override = []
 

Detailed Description

Notification Event Handler handles preparation of a notification.

Since
4.0

Definition at line 14 of file NotificationEventHandler.php.

Constructor & Destructor Documentation

◆ __construct()

Elgg\Notifications\NotificationEventHandler::__construct ( protected NotificationEvent  $event,
protected NotificationsService  $service,
array  $params = [] 
)

Constructor.

Parameters
NotificationEvent$eventevent to handle
NotificationsService$serviceservice that handles the events
array$paramsadditional params for event handling

Definition at line 35 of file NotificationEventHandler.php.

Member Function Documentation

◆ addMuteLink()

Elgg\Notifications\NotificationEventHandler::addMuteLink ( )
protected

◆ deliverNotification()

Elgg\Notifications\NotificationEventHandler::deliverNotification ( Notification  $notification,
string  $method 
)
finalprotected

Deliver a notification.

Parameters
Notification$notificationNotification to deliver
string$methodMethod to use for delivery
Returns
bool

Definition at line 333 of file NotificationEventHandler.php.

◆ excludeContainerSubscribers()

Elgg\Notifications\NotificationEventHandler::excludeContainerSubscribers ( )
protected

Exclude the NotificationEvent object container_guid when fetching the subscription records for this notification.

Returns
bool
See also
NotificationEventHandler::getSubscriptions();

Definition at line 185 of file NotificationEventHandler.php.

◆ excludeEntitySubscribers()

Elgg\Notifications\NotificationEventHandler::excludeEntitySubscribers ( )
protected

Exclude the NotificationEvent object guid when fetching the subscription records for this notification.

Returns
bool
See also
NotificationEventHandler::getSubscriptions();

Definition at line 195 of file NotificationEventHandler.php.

◆ excludeOwnerSubscribers()

Elgg\Notifications\NotificationEventHandler::excludeOwnerSubscribers ( )
protected

Exclude the NotificationEvent object owner_guid when fetching the subscription records for this notification.

Returns
bool
See also
NotificationEventHandler::getSubscriptions();

Reimplemented in Elgg\Notifications\CreateCommentEventHandler.

Definition at line 175 of file NotificationEventHandler.php.

◆ filterMutedSubscriptions()

Elgg\Notifications\NotificationEventHandler::filterMutedSubscriptions ( )
protected

Should muted subscribers be filtered.

Returns
bool
Since
4.1

Reimplemented in Elgg\Notifications\InstantNotificationEventHandler.

Definition at line 129 of file NotificationEventHandler.php.

◆ getEventActor()

Elgg\Notifications\NotificationEventHandler::getEventActor ( )
protected

Get the acting user from the notification event.

Returns
null|\ElggUser
Since
6.1

Definition at line 510 of file NotificationEventHandler.php.

◆ getEventEntity()

Elgg\Notifications\NotificationEventHandler::getEventEntity ( )
protected

Get the entity from the notification event.

Returns
null|\ElggEntity
Since
6.1

Definition at line 522 of file NotificationEventHandler.php.

◆ getMethods()

Elgg\Notifications\NotificationEventHandler::getMethods ( )
final

Returns methods to be used for this notification.

Returns
array

Definition at line 204 of file NotificationEventHandler.php.

◆ getMethodsOverride()

Elgg\Notifications\NotificationEventHandler::getMethodsOverride ( )
finalprotected

Get the delivery methods override.

Returns
string[]
Since
6.3

Definition at line 67 of file NotificationEventHandler.php.

◆ getNotificationAttachments()

Elgg\Notifications\NotificationEventHandler::getNotificationAttachments ( \ElggUser  $recipient,
string  $method 
)
protected

Get the attachments for this notification.

Parameters
\ElggUser$recipientNotification recipient
string$methodMethod
Returns
array

Definition at line 500 of file NotificationEventHandler.php.

◆ getNotificationBody()

Elgg\Notifications\NotificationEventHandler::getNotificationBody ( \ElggUser  $recipient,
string  $method 
)
protected

Get body for the notification.

Plugin can define a subtype specific body simply by providing a translation for the string "notification:<action>:<type>:<subtype>:body".

The arguments passed into the translation are:

  1. Recipient's name
  2. Name of the user who triggered the notification
  3. Title of the content
  4. Name of the content's container
  5. The actual content (entity's 'description' field)
  6. URL to the content

Argument swapping can be used to change the order of the parameters. See http://php.net/manual/en/function.sprintf.php#example-5427

Parameters
\ElggUser$recipientNotification recipient
string$methodMethod
Returns
string Notification body in the recipient's language

Reimplemented in Elgg\Notifications\UnbanUserEventHandler, Elgg\Notifications\RemoveAdminUserEventHandler, Elgg\Notifications\MentionsEventHandler, Elgg\Notifications\MakeAdminUserEventHandler, Elgg\Notifications\Handlers\ValidateUser, Elgg\Notifications\Handlers\ResetUserPassword, Elgg\Notifications\Handlers\RequestUserPassword, Elgg\Notifications\Handlers\ConfirmPasswordChange, Elgg\Notifications\Handlers\ConfirmEmailChange, Elgg\Notifications\Handlers\ChangeUserPassword, Elgg\Notifications\Handlers\BanUser, Elgg\Notifications\Handlers\AdminValidation, Elgg\Notifications\Handlers\AddUser, and Elgg\Notifications\CreateCommentEventHandler.

Definition at line 439 of file NotificationEventHandler.php.

◆ getNotificationMethods()

Elgg\Notifications\NotificationEventHandler::getNotificationMethods ( )
protected

◆ getNotificationSubject()

Elgg\Notifications\NotificationEventHandler::getNotificationSubject ( \ElggUser  $recipient,
string  $method 
)
protected

◆ getNotificationSubsciptionExclusionGUIDs()

Elgg\Notifications\NotificationEventHandler::getNotificationSubsciptionExclusionGUIDs ( )
finalprotected

Get an array of GUIDs to not get the subscription records for.

Returns
int[]

Definition at line 147 of file NotificationEventHandler.php.

◆ getNotificationSummary()

Elgg\Notifications\NotificationEventHandler::getNotificationSummary ( \ElggUser  $recipient,
string  $method 
)
protected

Return the summary for a notification.

Parameters
\ElggUser$recipientNotification recipient
string$methodMethod
Returns
string

Reimplemented in Elgg\Notifications\Handlers\AdminValidation, and Elgg\Notifications\CreateCommentEventHandler.

Definition at line 474 of file NotificationEventHandler.php.

◆ getNotificationURL()

Elgg\Notifications\NotificationEventHandler::getNotificationURL ( \ElggUser  $recipient,
string  $method 
)
protected

Returns the url related to this notification.

Parameters
\ElggUser$recipientNotification recipient
string$methodMethod
Returns
string

Reimplemented in Elgg\Notifications\RemoveAdminUserEventHandler, Elgg\Notifications\MakeAdminUserEventHandler, and Elgg\Notifications\Handlers\AdminValidation.

Definition at line 486 of file NotificationEventHandler.php.

◆ getParam()

Elgg\Notifications\NotificationEventHandler::getParam ( string  $param,
mixed  $default = null 
)
finalprotected

Get a parameter from the notification parameters.

Parameters
string$paramname of the parameter
mixed$defaultdefault value is not found
Returns
mixed

Definition at line 600 of file NotificationEventHandler.php.

◆ getSubscriptions()

Elgg\Notifications\NotificationEventHandler::getSubscriptions ( )

◆ isConfigurableByUser()

static Elgg\Notifications\NotificationEventHandler::isConfigurableByUser ( )
static

Is this event configurable by the user on the notification settings page.

Returns
bool

Reimplemented in Elgg\Notifications\NonConfigurableNotificationEventHandler.

Definition at line 533 of file NotificationEventHandler.php.

◆ isConfigurableForEntity()

static Elgg\Notifications\NotificationEventHandler::isConfigurableForEntity ( \ElggEntity  $entity)
staticfinal

Can this event be configured for a specific entity.

For example this can be based on a group tools option which is enabled or not

Parameters
\ElggEntity$entitythe entity to check for
Returns
bool
Since
4.1

Definition at line 547 of file NotificationEventHandler.php.

◆ isConfigurableForGroup()

static Elgg\Notifications\NotificationEventHandler::isConfigurableForGroup ( \ElggGroup  $group)
staticprotected

Can this event be configured for a specific group.

For example this can be based on a group tools option which is enabled or not

Parameters
\ElggGroup$groupthe group to check for
Returns
bool
Since
4.1

Reimplemented in Elgg\Notifications\NonConfigurableNotificationEventHandler.

Definition at line 579 of file NotificationEventHandler.php.

◆ isConfigurableForUser()

static Elgg\Notifications\NotificationEventHandler::isConfigurableForUser ( \ElggUser  $user)
staticprotected

Can this event be configured for a specific user.

Parameters
\ElggUser$userthe user to check for
Returns
bool
Since
4.1

Reimplemented in Elgg\Notifications\NonConfigurableNotificationEventHandler.

Definition at line 565 of file NotificationEventHandler.php.

◆ prepareNotification()

Elgg\Notifications\NotificationEventHandler::prepareNotification ( array  $params)
finalprotected

Prepares a notification for delivery.

Parameters
array$paramsParameters to initialize notification with
Returns
Notification
Exceptions
RuntimeException

Definition at line 362 of file NotificationEventHandler.php.

◆ prepareSubscriptions()

Elgg\Notifications\NotificationEventHandler::prepareSubscriptions ( )
finalprotected

Returns subscriptions.

Returns
array

Definition at line 110 of file NotificationEventHandler.php.

◆ send()

Elgg\Notifications\NotificationEventHandler::send ( )
final

Process the event.

Returns
array delivery information

Definition at line 86 of file NotificationEventHandler.php.

◆ sendNotification()

Elgg\Notifications\NotificationEventHandler::sendNotification ( \ElggEntity  $recipient,
string  $method,
array  $params = [] 
)
finalprotected

Send a notification to a subscriber.

Parameters
\ElggEntity$recipientThe recipient entity
string$methodThe notification method
array$paramsDefault notification params
Returns
bool

Definition at line 275 of file NotificationEventHandler.php.

◆ sendNotifications()

Elgg\Notifications\NotificationEventHandler::sendNotifications ( array  $subscriptions,
array  $params = [] 
)
finalprotected

Sends the notifications based on subscriptions.

Returns an array in the form: [ 25 => [ 'email' => true, 'sms' => false, ], 55 => [], ]

Parameters
array$subscriptionsSubscriptions for this event
array$paramsDefault notification parameters
Returns
array

Definition at line 227 of file NotificationEventHandler.php.

◆ setMethodsOverride()

Elgg\Notifications\NotificationEventHandler::setMethodsOverride ( array  $methods)
finalprotected

Override the default user preferred delivery methods with the given methods.

Parameters
string[]$methodsdelivery methods
Returns
void
Since
6.3

Definition at line 57 of file NotificationEventHandler.php.

Member Data Documentation

◆ $methods_override

array Elgg\Notifications\NotificationEventHandler::$methods_override = []
protected

Definition at line 26 of file NotificationEventHandler.php.

◆ $params

array Elgg\Notifications\NotificationEventHandler::$params = []
protected

Definition at line 21 of file NotificationEventHandler.php.


The documentation for this class was generated from the following file: