public function Role::prepareRecipients in Workbench Email 8
Same name and namespace in other branches
- 2.x src/Plugin/RecipientType/Role.php \Drupal\workbench_email\Plugin\RecipientType\Role::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
1 method overrides Role::prepareRecipients()
- RolesWithAccess::prepareRecipients in src/
Plugin/ RecipientType/ RolesWithAccess.php  - Returns email address(s) matching this recipient type's configuration.
 
File
- src/
Plugin/ RecipientType/ Role.php, line 101  
Class
- Role
 - Provides a recipient type of user role.
 
Namespace
Drupal\workbench_email\Plugin\RecipientTypeCode
public function prepareRecipients(ContentEntityInterface $entity, TemplateInterface $template) {
  $recipients = [];
  foreach ($this
    ->getRoles() as $role) {
    foreach ($this->entityTypeManager
      ->getStorage('user')
      ->loadByProperties([
      'roles' => $role,
      'status' => 1,
    ]) as $account) {
      $recipients[] = $account
        ->getEmail();
    }
  }
  return $recipients;
}