PHP Class Elgg\Notifications\NotificationsService

Since: 1.9.0
Datei anzeigen Open project: elgg/elgg Class Usage Examples

Protected Properties

Property Type Description
$deprHandlers Deprecated notification handlers
$deprSubjects Deprecated message subjects
$entities Elgg\Database\EntityTable
$events Registered notification events
$hooks Elgg\PluginHooksService
$logger Elgg\Logger
$methods Registered notification methods
$queue Elgg\Queue\Queue
$session ElggSessio\ElggSession
$subscriptions SubscriptionsService
$translator Elgg\I18n\Translator

Public Methods

Method Description
__construct ( SubscriptionsService $subscriptions, Elgg\Queue\Queue $queue, PluginHooksService $hooks, ElggSessio\ElggSession $session, Translator $translator, EntityTable $entities, Logger $logger ) Constructor
enqueueEvent ( string $action, string $type, ElggDat\ElggData $object ) : void Add a notification event to the queue
getDeprecatedHandler ( string $method ) : callback | null Get a deprecated notification handler callback
getEvents ( )
getMethods ( )
getMethodsAsDeprecatedGlobal ( ) : array Provides a way to incrementally wean Elgg's notifications code from the global $NOTIFICATION_HANDLERS
processQueue ( integer $stopTime, boolean $matrix = false ) : integer | array Pull notification events from queue until stop time is reached
registerDeprecatedHandler ( string $method, string $handler ) : void Register a deprecated notification handler
registerEvent ( $type, $subtype, array $actions = [] )
registerMethod ( $name )
sendInstantNotifications ( ElggEntity $sender, array $recipients = [], array $params = [] ) : array Notify a user via their preferences.
setDeprecatedNotificationSubject ( string $type, string $subtype, string $subject ) : void Set message subject for deprecated notification code
unregisterEvent ( $type, $subtype )
unregisterMethod ( $name )

Protected Methods

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

Private Methods

Method Description
getNotificationBody ( Elgg\Notifications\NotificationEvent $event, ElggUse\ElggUser $recipient ) : string Get body for the notification
getNotificationSubject ( Elgg\Notifications\NotificationEvent $event, ElggUse\ElggUser $recipient ) : string Get subject for the notification

Method Details

__construct() public method

Constructor
public __construct ( SubscriptionsService $subscriptions, Elgg\Queue\Queue $queue, PluginHooksService $hooks, ElggSessio\ElggSession $session, Translator $translator, EntityTable $entities, Logger $logger )
$subscriptions SubscriptionsService Subscription service
$queue Elgg\Queue\Queue Queue
$hooks Elgg\PluginHooksService Plugin hook service
$session ElggSessio\ElggSession Session service
$translator Elgg\I18n\Translator Translator
$entities Elgg\Database\EntityTable Entity table
$logger Elgg\Logger Logger

enqueueEvent() public method

Add a notification event to the queue
public enqueueEvent ( string $action, string $type, ElggDat\ElggData $object ) : void
$action string Action name
$type string Type of the object of the action
$object ElggDat\ElggData The object of the action
return void

getDeprecatedHandler() public method

Get a deprecated notification handler callback
public getDeprecatedHandler ( string $method ) : callback | null
$method string Method name
return callback | null

getDeprecatedNotificationBody() protected method

Get the notification body using a pre-Elgg 1.9 plugin hook
protected getDeprecatedNotificationBody ( Notification $notification, Elgg\Notifications\NotificationEvent $event, string $method ) : Notification
$notification Notification Notification
$event Elgg\Notifications\NotificationEvent Event
$method string Method
return Notification

getDeprecatedNotificationSubject() protected method

Get the deprecated subject
protected getDeprecatedNotificationSubject ( string $type, string $subtype ) : string
$type string Entity type
$subtype string Entity subtype
return string

getEvents() public method

public getEvents ( )

getMethods() public method

public getMethods ( )

getMethodsAsDeprecatedGlobal() public method

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

processQueue() public method

Pull notification events from queue until stop time is reached
public processQueue ( integer $stopTime, boolean $matrix = false ) : integer | array
$stopTime integer The Unix time to stop sending notifications
$matrix boolean If true, will return delivery matrix instead of a notifications event count
return integer | array The number of notification events handled, or a delivery matrix

registerDeprecatedHandler() public method

Register a deprecated notification handler
public registerDeprecatedHandler ( string $method, string $handler ) : void
$method string Method name
$handler string Handler callback
return void

registerEvent() public method

See also: elgg_register_notification_event()
public registerEvent ( $type, $subtype, array $actions = [] )
$actions array

registerMethod() public method

See also: elgg_register_notification_method()
public registerMethod ( $name )

sendInstantNotifications() public method

Returns an array in the form: [ 25 => [ 'email' => true, 'sms' => false, ], 55 => [], ]
public sendInstantNotifications ( ElggEntity $sender, array $recipients = [], array $params = [] ) : array
$sender ElggEntity Sender of the notification
$recipients array An array of entities to notify
$params array Notification parameters
return array

sendNotification() protected method

Send a notification to a subscriber
protected sendNotification ( Elgg\Notifications\NotificationEvent $event, integer $guid, string $method, array $params = [] ) : boolean
$event Elgg\Notifications\NotificationEvent The notification event
$guid integer The guid of the subscriber
$method string The notification method
$params array Default notification params
return boolean

sendNotifications() protected method

Returns an array in the form: [ 25 => [ 'email' => true, 'sms' => false, ], 55 => [], ]
protected sendNotifications ( Elgg\Notifications\NotificationEvent $event, array $subscriptions, array $params = [] ) : array
$event Elgg\Notifications\NotificationEvent Notification event
$subscriptions array Subscriptions for this event
$params array Default notification parameters
return array

setDeprecatedNotificationSubject() public method

Set message subject for deprecated notification code
public setDeprecatedNotificationSubject ( string $type, string $subtype, string $subject ) : void
$type string Entity type
$subtype string Entity subtype
$subject string Subject line
return void

unregisterEvent() public method

See also: elgg_unregister_notification_event()
public unregisterEvent ( $type, $subtype )

unregisterMethod() public method

See also: elgg_unregister_notification_method()
public unregisterMethod ( $name )

Property Details

$deprHandlers protected_oe property

Deprecated notification handlers
protected $deprHandlers

$deprSubjects protected_oe property

Deprecated message subjects
protected $deprSubjects

$entities protected_oe property

protected EntityTable,Elgg\Database $entities
return Elgg\Database\EntityTable

$events protected_oe property

Registered notification events
protected $events

$hooks protected_oe property

protected PluginHooksService,Elgg $hooks
return Elgg\PluginHooksService

$logger protected_oe property

protected Logger,Elgg $logger
return Elgg\Logger

$methods protected_oe property

Registered notification methods
protected $methods

$queue protected_oe property

protected Queue,Elgg\Queue $queue
return Elgg\Queue\Queue

$session protected_oe property

protected ElggSession,ElggSessio $session
return ElggSessio\ElggSession

$subscriptions protected_oe property

protected SubscriptionsService,Elgg\Notifications $subscriptions
return SubscriptionsService

$translator protected_oe property

protected Translator,Elgg\I18n $translator
return Elgg\I18n\Translator