Elgg  Version master
CreateCommentEventHandler.php
Go to the documentation of this file.
1 <?php
2 
4 
11 
20  return $this->event->getObject()->getContainerEntity()->owner_guid === $recipient->guid;
21  }
22 
26  protected function getNotificationSubject(\ElggUser $recipient, string $method): string {
27  return elgg_echo('generic_comment:notification:subject', [$this->event->getObject()->getContainerEntity()->getDisplayName()], $recipient->getLanguage());
28  }
29 
33  protected function getNotificationSummary(\ElggUser $recipient, string $method): string {
34  if ($this->recipientIsCommentContainerOwner($recipient)) {
35  return elgg_echo('generic_comment:notification:owner:summary', [$this->event->getObject()->getContainerEntity()->getDisplayName()], $recipient->getLanguage());
36  } else {
37  return elgg_echo('generic_comment:notification:user:summary', [$this->event->getObject()->getContainerEntity()->getDisplayName()], $recipient->getLanguage());
38  }
39  }
40 
44  protected function getNotificationBody(\ElggUser $recipient, string $method): string {
45  $entity = $this->event->getObject();
46 
47  $key = $this->recipientIsCommentContainerOwner($recipient) ? 'generic_comment:notification:owner:body' : 'generic_comment:notification:user:body';
48 
49  return elgg_echo($key, [
50  elgg_get_excerpt((string) $entity->description, 1000),
51  $entity->getURL(),
52  ], $recipient->getLanguage());
53  }
54 
60  public static function isConfigurableByUser(): bool {
61  return false;
62  }
63 
67  protected function excludeOwnerSubscribers(): bool {
68  return true;
69  }
70 }
recipientIsCommentContainerOwner(\ElggUser $recipient)
Tells if the recipient is the owner of the entity commented on.
elgg_get_excerpt(string $text, int $num_chars=250)
Returns an excerpt.
Definition: output.php:71
elgg_echo(string $message_key, array $args=[], string $language= '')
Elgg language module Functions to manage language and translations.
Definition: languages.php:17
getNotificationSubject(\ElggUser $recipient, string $method)
getNotificationBody(\ElggUser $recipient, string $method)
Notification Event Handler handles preparation of a notification.
$entity
Definition: reset.php:8
getLanguage(string $fallback=null)
Get user language or default to site language.
Definition: ElggUser.php:71
Notification Event Handler for &#39;object&#39; &#39;comment&#39; &#39;create&#39; action.
if($container instanceof ElggGroup &&$container->guid!=elgg_get_page_owner_guid()) $key
Definition: summary.php:44
static isConfigurableByUser()
Is this event configurable by the user on the notification settings page.
getNotificationSummary(\ElggUser $recipient, string $method)
$recipient
Definition: mute.php:8