Elgg  Version 4.3
CreateContentEventHandler.php
Go to the documentation of this file.
1 <?php
2 
3 namespace Elgg\Notifications;
4 
12 
20  public function __invoke(\Elgg\Event $event): void {
21  $entity = $event->getObject();
22  if (!$entity instanceof \ElggObject && !$entity instanceof \ElggGroup) {
23  return;
24  }
25 
26  $owner = $entity->getOwnerEntity();
27  if (!$owner instanceof \ElggUser) {
28  return;
29  }
30 
31  $content_preferences = $owner->getNotificationSettings('content_create');
32  $enabled_methods = array_keys(array_filter($content_preferences));
33 
34  // loop through all notification types
36  foreach ($enabled_methods as $method) {
37  // only enable supported methods
38  if (!in_array($method, $methods)) {
39  continue;
40  }
41 
42  $entity->addSubscription($owner->guid, $method);
43  }
44  }
45 }
$owner
Definition: upload.php:7
c Accompany it with the information you received as to the offer to distribute corresponding source complete source code means all the source code for all modules it plus any associated interface definition plus the scripts used to control compilation and installation of the executable as a special the source code distributed need not include anything that is normally and so on of the operating system on which the executable unless that component itself accompanies the executable If distribution of executable or object code is made by offering access to copy from a designated then offering equivalent access to copy the source code from the same place counts as distribution of the source even though third parties are not compelled to copy the source along with the object code You may not or distribute the Program except as expressly provided under this License Any attempt otherwise to sublicense or distribute the Program is void
Definition: LICENSE.txt:215
$entity
Definition: reset.php:8
Models an event passed to event handlers.
Definition: Event.php:11
elgg_get_notification_methods()
Returns registered delivery methods for notifications [ &#39;email&#39; => &#39;email&#39;, &#39;sms&#39; => &#39;sms&#39;...
$methods
Definition: subscribe.php:8
__invoke(\Elgg\Event $event)
Subscribe to content you just created in order to receive notifications.
Apply subscriptions based on preferences.