Elgg  Version 4.x
Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
Elgg\Notifications\NotificationsService Class Reference

Notifications service. More...

Public Member Functions

 __construct (Queue $queue, PluginHooksService $hooks,\ElggSession $session)
 Constructor. More...
 
 registerEvent ($type, $subtype, array $actions=[], string $handler=NotificationEventHandler::class)
 Register a notification event. More...
 
 unregisterEvent ($type, $subtype, array $actions=[])
 Unregister a notification event. More...
 
 getEvents ()
 Return the notification events. More...
 
 registerMethod ($name)
 Register a delivery method for notifications. More...
 
 unregisterMethod ($name)
 Unregister a delivery method for notifications. More...
 
 getMethods ()
 Returns registered delivery methods for notifications. More...
 
 isRegisteredMethod (string $method)
 Check if a notification method is registed. More...
 
 enqueueEvent ($action, $type, $object)
 Add a notification event to the queue. More...
 
 processQueue ($stopTime, $matrix=false)
 Pull notification events from queue until stop time is reached. More...
 
 sendInstantNotifications (\ElggEntity $sender, array $recipients=[], array $params=[])
 Notify a user via their preferences. More...
 

Protected Member Functions

 getNotificationHandler (NotificationEvent $event)
 Returns notification event handler based on event. More...
 

Protected Attributes

 $queue
 
 $hooks
 
 $session
 
 $events = []
 
 $methods = []
 

Detailed Description

Notifications service.

Definition at line 15 of file NotificationsService.php.

Constructor & Destructor Documentation

Elgg\Notifications\NotificationsService::__construct ( Queue  $queue,
PluginHooksService  $hooks,
\ElggSession  $session 
)

Constructor.

Parameters
Queue$queueQueue
PluginHooksService$hooksPlugin hook service
\ElggSession$sessionSession service

Definition at line 39 of file NotificationsService.php.

Member Function Documentation

Elgg\Notifications\NotificationsService::enqueueEvent (   $action,
  $type,
  $object 
)

Add a notification event to the queue.

Parameters
string$actionAction name
string$typeType of the object of the action
\ElggData$objectThe object of the action
Returns
void

Definition at line 186 of file NotificationsService.php.

Elgg\Notifications\NotificationsService::getEvents ( )

Return the notification events.

Returns
array

Definition at line 122 of file NotificationsService.php.

Elgg\Notifications\NotificationsService::getMethods ( )

Returns registered delivery methods for notifications.

Returns
string[]
See also
elgg_get_notification_methods()

Definition at line 162 of file NotificationsService.php.

Elgg\Notifications\NotificationsService::getNotificationHandler ( NotificationEvent  $event)
protected

Returns notification event handler based on event.

Parameters
NotificationEvent$eventevent to get event handler for
Returns
NotificationEventHandler

Definition at line 215 of file NotificationsService.php.

Elgg\Notifications\NotificationsService::isRegisteredMethod ( string  $method)

Check if a notification method is registed.

Parameters
string$methodthe notification method
Returns
bool

Definition at line 173 of file NotificationsService.php.

Elgg\Notifications\NotificationsService::processQueue (   $stopTime,
  $matrix = false 
)

Pull notification events from queue until stop time is reached.

Parameters
int$stopTimeThe Unix time to stop sending notifications
bool$matrixIf true, will return delivery matrix instead of a notifications event count
Returns
int|array The number of notification events handled, or a delivery matrix

Definition at line 234 of file NotificationsService.php.

Elgg\Notifications\NotificationsService::registerEvent (   $type,
  $subtype,
array  $actions = [],
string  $handler = NotificationEventHandler::class 
)

Register a notification event.

Parameters
string$type'object', 'user', 'group', 'site'
string$subtypeThe subtype or name of the entity
array$actionsArray of actions or empty array for the action event. An event is usually described by the first string passed to elgg_trigger_event(). Examples include 'create', 'update', and 'publish'. The default is 'create'.
string$handlerNotificationEventHandler classname
Returns
void
Exceptions
InvalidArgumentException
See also
elgg_register_notification_event()

Definition at line 65 of file NotificationsService.php.

Elgg\Notifications\NotificationsService::registerMethod (   $name)

Register a delivery method for notifications.

Parameters
string$nameThe notification method name
Returns
void
See also
elgg_register_notification_method()

Definition at line 134 of file NotificationsService.php.

Elgg\Notifications\NotificationsService::sendInstantNotifications ( \ElggEntity  $sender,
array  $recipients = [],
array  $params = [] 
)

Notify a user via their preferences.

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

Parameters
\ElggEntity$senderSender of the notification

Definition at line 303 of file NotificationsService.php.

Elgg\Notifications\NotificationsService::unregisterEvent (   $type,
  $subtype,
array  $actions = [] 
)

Unregister a notification event.

Parameters
string$type'object', 'user', 'group', 'site'
string$subtypeThe type of the entity
array$actionsThe notification action to unregister, leave empty for all actions
Returns
bool
See also
elgg_unregister_notification_event()

Definition at line 96 of file NotificationsService.php.

Elgg\Notifications\NotificationsService::unregisterMethod (   $name)

Unregister a delivery method for notifications.

Parameters
string$nameThe notification method name
Returns
bool
See also
elgg_unregister_notification_method()

Definition at line 146 of file NotificationsService.php.

Member Data Documentation

Elgg\Notifications\NotificationsService::$events = []
protected

Definition at line 27 of file NotificationsService.php.

Elgg\Notifications\NotificationsService::$hooks
protected

Definition at line 21 of file NotificationsService.php.

Elgg\Notifications\NotificationsService::$methods = []
protected

Definition at line 30 of file NotificationsService.php.

Elgg\Notifications\NotificationsService::$queue
protected

Definition at line 18 of file NotificationsService.php.

Elgg\Notifications\NotificationsService::$session
protected

Definition at line 24 of file NotificationsService.php.


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