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

WARNING: API IN FLUX. More...

Public Member Functions

 __construct (SubscriptionsService $subscriptions, Queue $queue, PluginHooksService $hooks, ElggSession $session, Translator $translator, EntityTable $entities, LoggerInterface $logger)
 Constructor. More...
 
 registerEvent ($type, $subtype, array $actions=[])
 Register a notification event. More...
 
 unregisterEvent ($type, $subtype)
 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...
 
 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...
 
 registerDeprecatedHandler ($method, $handler)
 Register a deprecated notification handler. More...
 
 getDeprecatedHandler ($method)
 Get a deprecated notification handler callback. More...
 
 getMethodsAsDeprecatedGlobal ()
 Provides a way to incrementally wean Elgg's notifications code from the global $NOTIFICATION_HANDLERS. More...
 
 setDeprecatedNotificationSubject ($type, $subtype, $subject)
 Set message subject for deprecated notification code. More...
 

Public Attributes

const QUEUE_NAME = 'notifications'
 

Protected Member Functions

 sendNotifications ($event, $subscriptions, array $params=[])
 Sends the notifications based on subscriptions. More...
 
 sendNotification (NotificationEvent $event, $guid, $method, array $params=[])
 Send a notification to a subscriber. More...
 
 getDeprecatedNotificationBody (Notification $notification, NotificationEvent $event, $method)
 Get the notification body using a pre-Elgg 1.9 plugin hook. More...
 
 getDeprecatedNotificationSubject ($type, $subtype)
 Get the deprecated subject. More...
 

Protected Attributes

 $subscriptions
 
 $queue
 
 $hooks
 
 $session
 
 $translator
 
 $entities
 
 $events = []
 
 $methods = []
 
 $deprHandlers = []
 
 $deprSubjects = []
 

Detailed Description

WARNING: API IN FLUX.

DO NOT USE DIRECTLY.

Definition at line 29 of file NotificationsService.php.

Constructor & Destructor Documentation

Elgg\Notifications\NotificationsService::__construct ( SubscriptionsService  $subscriptions,
Queue  $queue,
PluginHooksService  $hooks,
ElggSession  $session,
Translator  $translator,
EntityTable  $entities,
LoggerInterface  $logger 
)

Constructor.

Parameters
SubscriptionsService$subscriptionsSubscription service
Queue$queueQueue
PluginHooksService$hooksPlugin hook service
ElggSession$sessionSession service
Translator$translatorTranslator
EntityTable$entitiesEntity table
LoggerInterface$loggerLogger

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

Elgg\Notifications\NotificationsService::getDeprecatedHandler (   $method)

Get a deprecated notification handler callback.

Parameters
string$methodMethod name
Returns
callback|null

Definition at line 660 of file NotificationsService.php.

Elgg\Notifications\NotificationsService::getDeprecatedNotificationBody ( Notification  $notification,
NotificationEvent  $event,
  $method 
)
protected

Get the notification body using a pre-Elgg 1.9 plugin hook.

Parameters
Notification$notificationNotification
NotificationEvent$eventEvent
string$methodMethod
Returns
Notification

Definition at line 690 of file NotificationsService.php.

Elgg\Notifications\NotificationsService::getDeprecatedNotificationSubject (   $type,
  $subtype 
)
protected

Get the deprecated subject.

Parameters
string$typeEntity type
string$subtypeEntity subtype
Returns
string

Definition at line 742 of file NotificationsService.php.

Elgg\Notifications\NotificationsService::getEvents ( )

Return the notification events.

Returns
array

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

Elgg\Notifications\NotificationsService::getMethodsAsDeprecatedGlobal ( )

Provides a way to incrementally wean Elgg's notifications code from the global $NOTIFICATION_HANDLERS.

Returns
array

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

Elgg\Notifications\NotificationsService::registerDeprecatedHandler (   $method,
  $handler 
)

Register a deprecated notification handler.

Parameters
string$methodMethod name
string$handlerHandler callback
Returns
void

Definition at line 650 of file NotificationsService.php.

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

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'.
Returns
void
See also
elgg_register_notification_event()

Definition at line 107 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 162 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
ElggUser[]$recipients An array of entities to notify
array$paramsNotification parameters

$params['subject'] string Default message subject $params['body'] string Default message body $params['object'] null|| The object that is triggering the notification. $params['action'] null|string Word that describes the action that is triggering the notification (e.g. "create" or "update"). Defaults to "notify_user" $params['summary'] null|string Summary that notification plugins can use alongside the notification title and body. $params['methods_override'] string|array A string, or an array of strings specifying the delivery methods to use - or leave blank for delivery using the user's chosen delivery methods.

Returns
array

Definition at line 361 of file NotificationsService.php.

Elgg\Notifications\NotificationsService::sendNotification ( NotificationEvent  $event,
  $guid,
  $method,
array  $params = [] 
)
protected

Send a notification to a subscriber.

Parameters
NotificationEvent$eventThe notification event
int$guidThe guid of the subscriber
string$methodThe notification method
array$paramsDefault notification params
Returns
bool

Definition at line 433 of file NotificationsService.php.

Elgg\Notifications\NotificationsService::sendNotifications (   $event,
  $subscriptions,
array  $params = [] 
)
protected

Sends the notifications based on subscriptions.

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

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

Definition at line 305 of file NotificationsService.php.

Elgg\Notifications\NotificationsService::setDeprecatedNotificationSubject (   $type,
  $subtype,
  $subject 
)

Set message subject for deprecated notification code.

Parameters
string$typeEntity type
string$subtypeEntity subtype
string$subjectSubject line
Returns
void

Definition at line 720 of file NotificationsService.php.

Elgg\Notifications\NotificationsService::unregisterEvent (   $type,
  $subtype 
)

Unregister a notification event.

Parameters
string$type'object', 'user', 'group', 'site'
string$subtypeThe type of the entity
Returns
bool
See also
elgg_unregister_notification_event()

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

Member Data Documentation

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

Definition at line 60 of file NotificationsService.php.

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

Definition at line 63 of file NotificationsService.php.

Elgg\Notifications\NotificationsService::$entities
protected

Definition at line 51 of file NotificationsService.php.

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

Definition at line 54 of file NotificationsService.php.

Elgg\Notifications\NotificationsService::$hooks
protected

Definition at line 42 of file NotificationsService.php.

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

Definition at line 57 of file NotificationsService.php.

Elgg\Notifications\NotificationsService::$queue
protected

Definition at line 39 of file NotificationsService.php.

Elgg\Notifications\NotificationsService::$session
protected

Definition at line 45 of file NotificationsService.php.

Elgg\Notifications\NotificationsService::$subscriptions
protected

Definition at line 36 of file NotificationsService.php.

Elgg\Notifications\NotificationsService::$translator
protected

Definition at line 48 of file NotificationsService.php.

const Elgg\Notifications\NotificationsService::QUEUE_NAME = 'notifications'

Definition at line 33 of file NotificationsService.php.


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