Elgg\Notifications\Event::getObject PHP Method

getObject() public method

Get the object of the event
public getObject ( ) : ElggDat\ElggData | false | null
return ElggDat\ElggData | false | null
    public function getObject()
    {
        return $this->object;
    }

Usage Example

 /**
  * Get the subscriptions for this notification event
  *
  * The return array is of the form:
  *
  * array(
  *     <user guid> => array('email', 'sms', 'ajax'),
  * );
  *
  * @param \Elgg\Notifications\Event $event Notification event
  * @return array
  */
 public function getSubscriptions(\Elgg\Notifications\Event $event)
 {
     $subscriptions = array();
     if (!$this->methods) {
         return $subscriptions;
     }
     $object = $event->getObject();
     if (!$object) {
         return $subscriptions;
     }
     $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);
     return _elgg_services()->hooks->trigger('get', 'subscriptions', $params, $subscriptions);
 }
All Usage Examples Of Elgg\Notifications\Event::getObject