Elgg  Version 6.1
CreateCommentEventHandler.php
Go to the documentation of this file.
1 <?php
2 
4 
11 
20  return $this->getEventEntity()?->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->getEventEntity()?->getContainerEntity()?->getDisplayName()]);
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->getEventEntity()?->getContainerEntity()?->getDisplayName()]);
36  } else {
37  return elgg_echo('generic_comment:notification:user:summary', [$this->getEventEntity()?->getContainerEntity()?->getDisplayName()]);
38  }
39  }
40 
44  protected function getNotificationBody(\ElggUser $recipient, string $method): string {
45  $entity = $this->getEventEntity();
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  ]);
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:83
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)
{}
getEventEntity()
Get the entity from the notification event.
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.
$site description
Definition: settings.php:14
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