NotificationManager
in package
The NotificationManager component is responsible for sending BaseNotifications to Users over different notification targets by using the send and sendBulk function.
A notification target may be disabled for a specific user and will be skipped.
Tags
Table of Contents
Constants
- EVENT_SEARCH_MODULE_NOTIFICATIONS = 'searchModuleNotifications'
- Sends the notifications categories in the results
- IS_TOUCHED_SETTINGS = 'is_touched_settings'
- User setting name to know if the user has modified default notification settings
Properties
- $targets : array<string|int, mixed>
- $_categories : array<string|int, NotificationCategory>
- Cached array of NotificationCategories
- $_notifications : array<string|int, BaseNotification>
- $_targets : array<string|int, BaseTarget>
Methods
- getContainerFollowers() : ActiveQueryUser
- Returns all notification followers for the given $container. If $public is set to false only members with send_notifications settings are returned.
- getDesktopNoficationSettings() : int
- Determines the enable_html5_desktop_notifications setting either for the given user or global if no user is given.
- getFollowers() : ActiveQueryUser
- Returns all notification followers for the given $content instance.
- getNonNotificationSpaces() : array<string|int, Space>
- Returns all spaces this user is not following.
- getNotificationCategories() : mixed
- Returns all available NotificationCategories as array with category id as key and a category instance as value.
- getNotifications() : array<string|int, BaseNotification>
- Returns all available Notifications
- getSpaces() : array<string|int, Space>
- Returns all spaces this user is following (including member spaces) with sent_notification setting.
- getTarget() : BaseTarget
- Factory function for receiving a target instance for the given class.
- getTargets() : array<string|int, BaseTarget>
- Returns all active targets for the given user.
- hasSpace() : bool
- Check if notifications are sent from the given Space to the given or current user
- isFollowingSpace() : bool
- Checks if the given user is following notifications for the given space.
- isTouchedSettings() : bool
- resetSpaces() : mixed
- Reset the notification space settings for all users
- send() : mixed
- Sends the given $notification to all enabled targets of a single user.
- sendBulk() : mixed
- Sends the given $notification to all enabled targets of the given $users if possible as bulk message.
- setDesktopNoficationSettings() : mixed
- Defines the enable_html5_desktop_notifications setting for the given user or global if no user is given.
- setSpaces() : mixed
- Sets the notification space settings for this user (or global if no user is given).
- setSpaceSetting() : mixed
- Sets the send_notifications settings for the given space and user.
- createNotifications() : mixed
- searchModuleNotifications() : array<string|int, mixed>
- Searches for all Notifications exported by modules.
- findFollowers() : mixed
- findNotExistingSettingSubQuery() : mixed
- isDefaultNotificationSpace() : mixed
Constants
EVENT_SEARCH_MODULE_NOTIFICATIONS
Sends the notifications categories in the results
public
mixed
EVENT_SEARCH_MODULE_NOTIFICATIONS
= 'searchModuleNotifications'
IS_TOUCHED_SETTINGS
User setting name to know if the user has modified default notification settings
public
mixed
IS_TOUCHED_SETTINGS
= 'is_touched_settings'
Properties
$targets
public
array<string|int, mixed>
$targets
= []
Target configuration.
$_categories
Cached array of NotificationCategories
protected
array<string|int, NotificationCategory>
$_categories
$_notifications
protected
array<string|int, BaseNotification>
$_notifications
Cached array of BaseNotification instances.
$_targets
protected
array<string|int, BaseTarget>
$_targets
= null
Cached target instances.
Methods
getContainerFollowers()
Returns all notification followers for the given $container. If $public is set to false only members with send_notifications settings are returned.
public
getContainerFollowers(ContentContainerActiveRecord $container[, bool $public = true ]) : ActiveQueryUser
Parameters
- $container : ContentContainerActiveRecord
- $public : bool = true
Return values
ActiveQueryUsergetDesktopNoficationSettings()
Determines the enable_html5_desktop_notifications setting either for the given user or global if no user is given.
public
getDesktopNoficationSettings([User $user = null ]) : int
By default the setting is enabled.
Parameters
- $user : User = null
Return values
intgetFollowers()
Returns all notification followers for the given $content instance.
public
getFollowers(Content $content) : ActiveQueryUser
This function includes ContentContainer followers only if the content visibility is set to public, else only space members with send_notifications settings are returned.
Parameters
- $content : Content
Tags
Return values
ActiveQueryUsergetNonNotificationSpaces()
Returns all spaces this user is not following.
public
getNonNotificationSpaces([User $user = null ][, mixed $limit = 25 ]) : array<string|int, Space>
Parameters
- $user : User = null
- $limit : mixed = 25
Return values
array<string|int, Space>getNotificationCategories()
Returns all available NotificationCategories as array with category id as key and a category instance as value.
public
getNotificationCategories([mixed $user = null ]) : mixed
Parameters
- $user : mixed = null
getNotifications()
Returns all available Notifications
public
getNotifications() : array<string|int, BaseNotification>
Tags
Return values
array<string|int, BaseNotification>getSpaces()
Returns all spaces this user is following (including member spaces) with sent_notification setting.
public
getSpaces(User $user) : array<string|int, Space>
Parameters
- $user : User
Return values
array<string|int, Space>getTarget()
Factory function for receiving a target instance for the given class.
public
getTarget(string $class) : BaseTarget
Parameters
- $class : string
Tags
Return values
BaseTargetgetTargets()
Returns all active targets for the given user.
public
getTargets([User $user = null ]) : array<string|int, BaseTarget>
If no user is given, all configured targets will be returned.
Parameters
- $user : User = null
-
|null the user
Tags
Return values
array<string|int, BaseTarget> —the target
hasSpace()
Check if notifications are sent from the given Space to the given or current user
public
hasSpace(Space $space[, User|null $user = null ]) : bool
Parameters
Tags
Return values
boolisFollowingSpace()
Checks if the given user is following notifications for the given space.
public
isFollowingSpace(User $user, Space $space) : bool
This is the case for members and followers with the sent_notifications settings.
Parameters
Return values
boolisTouchedSettings()
public
static isTouchedSettings(User $user) : bool
Parameters
- $user : User
Tags
Return values
boolresetSpaces()
Reset the notification space settings for all users
public
resetSpaces() : mixed
send()
Sends the given $notification to all enabled targets of a single user.
public
send(BaseNotification $notification, User $user) : mixed
Parameters
- $notification : BaseNotification
- $user : User
-
target user
Tags
sendBulk()
Sends the given $notification to all enabled targets of the given $users if possible as bulk message.
public
sendBulk(BaseNotification $notification, ActiveQueryUser $userQuery) : mixed
Parameters
- $notification : BaseNotification
- $userQuery : ActiveQueryUser
Tags
setDesktopNoficationSettings()
Defines the enable_html5_desktop_notifications setting for the given user or global if no user is given.
public
setDesktopNoficationSettings([int $value = 0 ][, User $user = null ]) : mixed
Parameters
- $value : int = 0
- $user : User = null
setSpaces()
Sets the notification space settings for this user (or global if no user is given).
public
setSpaces(array<string|int, string> $spaceGuids[, User $user = null ]) : mixed
Those are the spaces for which the user want to receive ContentCreated Notifications.
Parameters
- $spaceGuids : array<string|int, string>
-
array of space guids
- $user : User = null
setSpaceSetting()
Sets the send_notifications settings for the given space and user.
public
setSpaceSetting([User $user = null ], Space $space[, bool $follow = true ]) : mixed
Parameters
createNotifications()
protected
createNotifications(mixed $notificationClasses) : mixed
Parameters
- $notificationClasses : mixed
searchModuleNotifications()
Searches for all Notifications exported by modules.
protected
searchModuleNotifications() : array<string|int, mixed>
Tags
Return values
array<string|int, mixed>findFollowers()
private
findFollowers(mixed $container[, mixed $isDefault = false ]) : mixed
Parameters
- $container : mixed
- $isDefault : mixed = false
findNotExistingSettingSubQuery()
private
findNotExistingSettingSubQuery() : mixed
isDefaultNotificationSpace()
private
isDefaultNotificationSpace(mixed $container) : mixed
Parameters
- $container : mixed