public function Role::displayCategories in Mass Contact 8
Display list of categories.
Parameters
array $categories: An array of category IDs.
Return value
string Display included categories as a string.
Overrides GroupingInterface::displayCategories
File
- src/
Plugin/ MassContact/ GroupingMethod/ Role.php, line 77
Class
- Role
- Select users by their role.
Namespace
Drupal\mass_contact\Plugin\MassContact\GroupingMethodCode
public function displayCategories(array $categories) {
/** @var \Drupal\user\RoleInterface[] $roles */
$roles = $this->entityTypeManager
->getStorage('user_role')
->loadMultiple($categories);
$labels = [];
foreach ($roles as $role) {
$labels[] = $role
->label();
}
if (!empty($labels)) {
return new FormattableMarkup($this
->t('Roles: %roles', [
'%roles' => implode(', ', $labels),
]), []);
}
return '';
}