You are here

public function Template::getRecipients in Workbench Email 8

Same name and namespace in other branches
  1. 2.x src/Entity/Template.php \Drupal\workbench_email\Entity\Template::getRecipients()

Calculates recipients.

Parameters

\Drupal\Core\Entity\ContentEntityInterface $entity: Entity being sent.

Return value

array Array of email addresses.

Overrides TemplateInterface::getRecipients

File

src/Entity/Template.php, line 230

Class

Template
Defines the Email Template entity.

Namespace

Drupal\workbench_email\Entity

Code

public function getRecipients(ContentEntityInterface $entity) {
  $recipients = [];
  foreach ($this->recipient_types as $plugin_id => $config) {
    $recipientType = $this
      ->recipientTypes($plugin_id);
    if (!$recipientType
      ->isEnabled()) {
      continue;
    }
    $recipients = array_merge($recipients, $recipientType
      ->prepareRecipients($entity, $this));
  }
  return array_filter(array_unique($recipients));
}