getSender() 공개 메소드

Get the sender entity
public getSender ( ) : ElggEntity
리턴 ElggEntity
예제 #1
0
 /**
  * Get the subscribers for a new group which needs admin approval
  *
  * @param string                           $hook         the name of the hook
  * @param string                           $type         the type of the hook
  * @param \Elgg\Notifications\Notification $return_value current return value
  * @param array                            $params       supplied params
  *
  * @return void|\Elgg\Notifications\Notification
  */
 public static function prepareAdminApprovalMessage($hook, $type, $return_value, $params)
 {
     if (!$return_value instanceof \Elgg\Notifications\Notification) {
         return;
     }
     $actor = $return_value->getSender();
     $recipient = $return_value->getRecipient();
     $language = elgg_extract('language', $params);
     $event = elgg_extract('event', $params);
     if (!$event instanceof \Elgg\Notifications\Event) {
         return;
     }
     $group = $event->getObject();
     if (!$group instanceof \ElggGroup) {
         return;
     }
     $return_value->subject = elgg_echo('group_tools:group:admin_approve:admin:subject', [$group->name], $language);
     $return_value->summary = elgg_echo('group_tools:group:admin_approve:admin:summary', [$group->name], $language);
     $return_value->body = elgg_echo('group_tools:group:admin_approve:admin:message', [$recipient->name, $actor->name, $group->name, $group->getURL(), elgg_normalize_url('admin/groups/admin_approval')], $language);
     return $return_value;
 }
/**
 * Formats notifications that have defined template
 * 
 * @param string                           $hook         "format"
 * @param string                           $type         "notification"
 * @param \Elgg\Notifications\Notification $notification Notification
 * @param array                            $params       Hook params
 * @return \Elgg\Notifications\Notification
 */
function notifications_editor_format_notification($hook, $type, $notification, $params)
{
    $language = $notification->language;
    if (empty($notification->params['template'])) {
        return;
    }
    $template = notifications_editor_get_template_entity($notification->params['template'], $language);
    if (!$template) {
        return;
    }
    $event = elgg_extract('event', $params);
    if ($event instanceof \Elgg\Notifications\Event) {
        $action = $event->getAction();
        $actor = $event->getActor();
        $object = $event->getObject();
        if ($object instanceof ElggEntity) {
            $target = $object->getContainerEntity();
        } else {
            if ($object instanceof ElggRelationship) {
                $target = array('subject' => get_entity($object->guid_one), 'object' => get_entity($object->guid_two));
            } else {
                if ($object instanceof ElggAnnotation) {
                    $target = $object->getEntity();
                }
            }
        }
    }
    $template_params = array('action' => $action, 'actor' => $actor, 'object' => $object, 'target' => $target, 'recipient' => $notification->getRecipient(), 'sender' => $notification->getSender(), 'language' => $language, 'site' => elgg_get_site_entity(), 'params' => $notification->params);
    elgg_push_context('widgets');
    if ($template->subject) {
        $notification->subject = mustache()->render($template->subject, $template_params);
    }
    if ($template->body) {
        $notification->body = mustache()->render($template->body, $template_params);
    }
    if ($template->summary) {
        $notification->summary = mustache()->render($template->summary, $template_params);
    }
    elgg_pop_context();
    return $notification;
}