getDescription() public method

Get a description of the event
public getDescription ( ) : string
return string
Exemplo n.º 1
0
 /**
  * Get body for the notification
  *
  * Plugin can define a subtype specific body simply by providing a
  * translation for the string "notification:body:<action>:<type>:<subtype".
  *
  * For example in mod/blog/languages/en.php:
  *
  *    'notification:body:publish:object:blog' => '
  *         Hi %s!
  *
  *         %s has created a new post called "%s" in the group %s.
  *
  *         It says:
  *
  *         "%s"
  *
  *         You can comment the post here:
  *         %s
  *     ',
  *
  * The arguments passed into the translation are:
  *     1. Recipient's name
  *     2. Name of the user who triggered the notification
  *     3. Title of the content
  *     4. Name of the content's container
  *     5. The actual content (entity's 'description' field)
  *     6. URL to the content
  *
  * Argument swapping can be used to change the order of the parameters.
  * See http://php.net/manual/en/function.sprintf.php#example-5427
  *
  * @param NotificationEvent $event     Notification event
  * @param ElggUser          $recipient Notification recipient
  * @return string Notification body in the recipient's language
  */
 private function getNotificationBody(NotificationEvent $event, ElggUser $recipient)
 {
     $actor = $event->getActor();
     $object = $event->getObject();
     /* @var \ElggObject $object */
     $language = $recipient->language;
     // Check custom notification body for the action/type/subtype combination
     $body_key = "notification:{$event->getDescription()}:body";
     if ($this->translator->languageKeyExists($body_key, $language)) {
         if ($object instanceof \ElggEntity) {
             $display_name = $object->getDisplayName();
             $container_name = '';
             $container = $object->getContainerEntity();
             if ($container) {
                 $container_name = $container->getDisplayName();
             }
         } else {
             $display_name = '';
             $container_name = '';
         }
         return $this->translator->translate($body_key, array($recipient->name, $actor->name, $display_name, $container_name, $object->description, $object->getURL()), $language);
     }
     // Fall back to default body
     return $this->translator->translate('notification:body', array($object->getURL()), $language);
 }