You are here

public function Author::prepareRecipients in Workbench Email 2.x

Same name and namespace in other branches
  1. 8 src/Plugin/RecipientType/Author.php \Drupal\workbench_email\Plugin\RecipientType\Author::prepareRecipients()

Returns email address(s) matching this recipient type's configuration.

Parameters

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

\Drupal\workbench_email\TemplateInterface $template: Template being used.

Overrides RecipientTypeBase::prepareRecipients

File

src/Plugin/RecipientType/Author.php, line 24

Class

Author
Provides a recipient type of the content author.

Namespace

Drupal\workbench_email\Plugin\RecipientType

Code

public function prepareRecipients(ContentEntityInterface $entity, TemplateInterface $template) {
  $recipients = [];
  if ($this
    ->isEnabled() && $entity instanceof EntityOwnerInterface) {
    if (!$entity
      ->getOwner()
      ->isAnonymous()) {
      $recipients[] = $entity
        ->getOwner()
        ->getEmail();
    }
  }
  return $recipients;
}