public function RolesWithAccess::prepareRecipients in Workbench Email 8
Same name and namespace in other branches
- 2.x src/Plugin/RecipientType/RolesWithAccess.php \Drupal\workbench_email\Plugin\RecipientType\RolesWithAccess::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 Role::prepareRecipients
File
- src/
Plugin/ RecipientType/ RolesWithAccess.php, line 40
Class
- RolesWithAccess
- Provides a recipient type for Workbench Access Sections.
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) {
if ($entity
->access('update', $account)) {
$recipients[] = $account
->getEmail();
}
}
}
return $recipients;
}