PHP Class Elgg\Notifications\SubscriptionsService

Since: 1.9.0
Mostra file Open project: elgg/elgg Class Usage Examples

Public Properties

Property Type Description
$methods Array of strings. Delivery names as registered with elgg_register_notification_method()

Protected Properties

Property Type Description
$db Elgg\Database

Public Methods

Method Description
__construct ( Database $db, array $methods = [] ) Constructor
addSubscription ( integer $userGuid, string $method, integer $targetGuid ) : boolean Subscribe a user to notifications about a target entity
getSubscriptions ( Elgg\Notifications\NotificationEvent $event ) : array Get the subscriptions for this notification event
getSubscriptionsForContainer ( integer $container_guid ) : array Get the subscriptions for the content created inside this container.
removeSubscription ( integer $userGuid, string $method, integer $targetGuid ) : boolean Unsubscribe a user to notifications about a target entity

Protected Methods

Method Description
getMethodRelationships ( ) : array Get the relationship names for notifications
getSubscriptionRecords ( integer $container_guid ) : array Get subscription records from the database

Method Details

__construct() public method

Constructor
public __construct ( Database $db, array $methods = [] )
$db Elgg\Database Database object
$methods array Notification delivery method names

addSubscription() public method

This method will return false if the subscription already exists.
public addSubscription ( integer $userGuid, string $method, integer $targetGuid ) : boolean
$userGuid integer The GUID of the user to subscribe to notifications
$method string The delivery method of the notifications
$targetGuid integer The entity to receive notifications about
return boolean

getMethodRelationships() protected method

Get the relationship names for notifications
protected getMethodRelationships ( ) : array
return array

getSubscriptionRecords() protected method

Records are an object with two vars: guid and methods with the latter being a comma-separated list of subscription relationship names.
protected getSubscriptionRecords ( integer $container_guid ) : array
$container_guid integer The GUID of the subscription target
return array

getSubscriptions() public method

The return array is of the form: array( => array('email', 'sms', 'ajax'), );
public getSubscriptions ( Elgg\Notifications\NotificationEvent $event ) : array
$event Elgg\Notifications\NotificationEvent Notification event
return array

getSubscriptionsForContainer() public method

The return array is of the form: array( => array('email', 'sms', 'ajax'), );
public getSubscriptionsForContainer ( integer $container_guid ) : array
$container_guid integer GUID of the entity acting as a container
return array User GUIDs (keys) and their subscription types (values).

removeSubscription() public method

Unsubscribe a user to notifications about a target entity
public removeSubscription ( integer $userGuid, string $method, integer $targetGuid ) : boolean
$userGuid integer The GUID of the user to unsubscribe to notifications
$method string The delivery method of the notifications to stop
$targetGuid integer The entity to stop receiving notifications about
return boolean

Property Details

$db protected_oe property

protected Database,Elgg $db
return Elgg\Database

$methods public_oe property

Array of strings. Delivery names as registered with elgg_register_notification_method()
public $methods