Elgg  Version master
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,\ElggSession $session, EventsService $elgg_events)
 Constructor. More...
 
 registerEvent (string $type, string $subtype, array $actions=[], string $handler=NotificationEventHandler::class)
 Register a notification event. More...
 
 unregisterEvent (string $type, string $subtype, array $actions=[])
 Unregister a notification event. More...
 
 isRegisteredEvent (string $type, string $subtype, string $action)
 Check if a notification event is registered. More...
 
 getEvents ()
 Return the notification events. More...
 
 registerMethod (string $name)
 Register a delivery method for notifications. More...
 
 unregisterMethod (string $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 (string $action,\ElggData $object,\ElggEntity $actor=null)
 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
 
 $elgg_events
 
 $session
 
 $events = []
 
 $methods = []
 

Detailed Description

Notifications service.

Definition at line 16 of file NotificationsService.php.

Constructor & Destructor Documentation

Elgg\Notifications\NotificationsService::__construct ( Queue  $queue,
\ElggSession  $session,
EventsService  $elgg_events 
)

Constructor.

Parameters
Queue$queueQueue
\ElggSession$sessionSession service
EventsService$elgg_eventsEvents service

Definition at line 42 of file NotificationsService.php.

Member Function Documentation

Elgg\Notifications\NotificationsService::enqueueEvent ( string  $action,
\ElggData  $object,
\ElggEntity  $actor = null 
)

Add a notification event to the queue.

Parameters
string$actionAction name
\ElggData$objectThe object of the action
\ElggEntity$actor(optional) The actor of the notification (default: logged in user or owner of $object)
Returns
void

Definition at line 200 of file NotificationsService.php.

Elgg\Notifications\NotificationsService::getEvents ( )

Return the notification events.

Returns
array

Definition at line 138 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 176 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 234 of file NotificationsService.php.

Elgg\Notifications\NotificationsService::isRegisteredEvent ( string  $type,
string  $subtype,
string  $action 
)

Check if a notification event is registered.

Parameters
string$type'object', 'user', 'group', 'site'
string$subtypeThe subtype of the entity
string$actionThe notification action to check
Returns
bool
Since
5.0

Definition at line 129 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 187 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 253 of file NotificationsService.php.

Elgg\Notifications\NotificationsService::registerEvent ( string  $type,
string  $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 68 of file NotificationsService.php.

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

Register a delivery method for notifications.

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

Definition at line 150 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 327 of file NotificationsService.php.

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

Unregister a notification event.

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

Definition at line 100 of file NotificationsService.php.

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

Unregister a delivery method for notifications.

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

Definition at line 162 of file NotificationsService.php.

Member Data Documentation

Elgg\Notifications\NotificationsService::$elgg_events
protected

Definition at line 24 of file NotificationsService.php.

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

Definition at line 30 of file NotificationsService.php.

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

Definition at line 33 of file NotificationsService.php.

Elgg\Notifications\NotificationsService::$queue
protected

Definition at line 21 of file NotificationsService.php.

Elgg\Notifications\NotificationsService::$session
protected

Definition at line 27 of file NotificationsService.php.


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