Elgg\Notifications\SubscriptionsService::getSubscriptions PHP Метод

getSubscriptions() публичный Метод

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
Результат array
    public function getSubscriptions(NotificationEvent $event)
    {
        $subscriptions = array();
        if (!$this->methods) {
            return $subscriptions;
        }
        $object = $event->getObject();
        if (!$object) {
            return $subscriptions;
        }
        // get subscribers only for \ElggEntity if it isn't private
        if ($object instanceof \ElggEntity && $object->access_id !== ACCESS_PRIVATE) {
            $prefixLength = strlen(self::RELATIONSHIP_PREFIX);
            $records = $this->getSubscriptionRecords($object->getContainerGUID());
            foreach ($records as $record) {
                $deliveryMethods = explode(',', $record->methods);
                $subscriptions[$record->guid] = substr_replace($deliveryMethods, '', 0, $prefixLength);
            }
        }
        $params = array('event' => $event, 'origin' => Notification::ORIGIN_SUBSCRIPTIONS);
        return _elgg_services()->hooks->trigger('get', 'subscriptions', $params, $subscriptions);
    }

Usage Example

Пример #1
0
 /**
  * Pull notification events from queue until stop time is reached
  *
  * @param int $stopTime The Unix time to stop sending notifications
  * @return int The number of notification events handled
  * @access private
  */
 public function processQueue($stopTime)
 {
     $this->subscriptions->methods = $this->methods;
     $count = 0;
     // @todo grab mutex
     $ia = $this->session->setIgnoreAccess(true);
     while (time() < $stopTime) {
         // dequeue notification event
         $event = $this->queue->dequeue();
         if (!$event) {
             break;
         }
         // test for usage of the deprecated override hook
         if ($this->existsDeprecatedNotificationOverride($event)) {
             continue;
         }
         $subscriptions = $this->subscriptions->getSubscriptions($event);
         // return false to stop the default notification sender
         $params = array('event' => $event, 'subscriptions' => $subscriptions);
         if ($this->hooks->trigger('send:before', 'notifications', $params, true)) {
             $this->sendNotifications($event, $subscriptions);
         }
         $this->hooks->trigger('send:after', 'notifications', $params);
         $count++;
     }
     // release mutex
     $this->session->setIgnoreAccess($ia);
     return $count;
 }
All Usage Examples Of Elgg\Notifications\SubscriptionsService::getSubscriptions