Elgg
Version master
engine
classes
Elgg
Comments
AutoSubscribeHandler.php
Go to the documentation of this file.
1
<?php
2
3
namespace
Elgg\Comments
;
4
12
class
AutoSubscribeHandler
{
13
21
public
function
__invoke
(\
Elgg
\
Event
$event): void {
22
$object
= $event->getObject();
23
if
(!
$object
instanceof \
ElggComment
) {
24
return
;
25
}
26
27
$owner
=
$object
->getOwnerEntity();
28
$container
=
$object
->getContainerEntity();
29
if
(!
$owner
instanceof \
ElggUser
|| !
$container
instanceof \
ElggEntity
) {
30
return
;
31
}
32
33
if
(
$container
->hasMutedNotifications(
$owner
->guid)) {
34
// user already said to not receive notifications, so don't force it
35
return
;
36
}
37
38
$comment_preferences =
$owner
->getNotificationSettings(
'create_comment'
);
39
$enabled_methods = array_keys(array_filter($comment_preferences));
40
if
(empty($enabled_methods)) {
41
return
;
42
}
43
44
$container
->addSubscription(
$owner
->guid, $enabled_methods);
45
}
46
}
$owner
$owner
Definition:
upload.php:7
$container
$container
Definition:
delete.php:23
ElggComment
Definition:
ElggComment.php:11
ElggEntity
Definition:
ElggEntity.php:52
ElggUser
Definition:
ElggUser.php:28
Elgg\Comments\AutoSubscribeHandler
When a comment is created subscribe the owner to the container (original content) of the comment if t...
Definition:
AutoSubscribeHandler.php:12
Elgg\Comments\AutoSubscribeHandler\__invoke
__invoke(\Elgg\Event $event)
Subscribe the user to the comment container.
Definition:
AutoSubscribeHandler.php:21
Elgg\Event
Models an event passed to event handlers.
Definition:
Event.php:11
$object
if($email instanceof \Elgg\Email) $object
Definition:
body.php:24
Elgg\Comments
Definition:
AutoSubscribeHandler.php:3
Elgg
Definition:
ActionsService.php:3
Generated on Fri Aug 29 2025 00:01:57 for Elgg by
1.9.1