Elgg  Version 4.3
CreateCommentEventHandler.php
Go to the documentation of this file.
1 <?php
2 
4 
11 
18  return $this->event->getObject()->getContainerEntity()->owner_guid === $recipient->guid;
19  }
20 
24  protected function getNotificationSubject(\ElggUser $recipient, string $method): string {
25  return elgg_echo('generic_comment:notification:subject', [$this->event->getObject()->getContainerEntity()->getDisplayName()], $recipient->getLanguage());
26  }
27 
31  protected function getNotificationSummary(\ElggUser $recipient, string $method): string {
32  if ($this->recipientIsCommentContainerOwner($recipient)) {
33  return elgg_echo('generic_comment:notification:owner:summary', [$this->event->getObject()->getContainerEntity()->getDisplayName()], $recipient->getLanguage());
34  } else {
35  return elgg_echo('generic_comment:notification:user:summary', [$this->event->getObject()->getContainerEntity()->getDisplayName()], $recipient->getLanguage());
36  }
37  }
38 
42  protected function getNotificationBody(\ElggUser $recipient, string $method): string {
43  $entity = $this->event->getObject();
44 
45  $key = $this->recipientIsCommentContainerOwner($recipient) ? 'generic_comment:notification:owner:body' : 'generic_comment:notification:user:body';
46 
47  return elgg_echo($key, [
48  elgg_get_excerpt($entity->description, 1000),
49  $entity->getURL(),
50  ], $recipient->getLanguage());
51  }
52 
58  public static function isConfigurableByUser(): bool {
59  return false;
60  }
61 
65  protected function excludeOwnerSubscribers(): bool {
66  return true;
67  }
68 }
getLanguage($fallback=null)
Get user language or default to site language.
Definition: ElggUser.php:73
recipientIsCommentContainerOwner(\ElggUser $recipient)
Tells if the recipient is the owner of the entity commented on.
getNotificationSubject(\ElggUser $recipient, string $method)
elgg_echo($message_key, array $args=[], $language="")
Elgg language module Functions to manage language and translations.
Definition: languages.php:18
getNotificationBody(\ElggUser $recipient, string $method)
Notification Event Handler handles preparation of a notification.
$entity
Definition: reset.php:8
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)
elgg_get_excerpt($text, $num_chars=250)
Returns an excerpt.
Definition: output.php:72
$recipient
Definition: mute.php:8