public function HideOnRole::summary in Field Formatter Condition 8
Return the summary string.
Parameters
array $settings: The current settings array.
Overrides FieldFormatterConditionBase::summary
File
- src/
Plugin/ Field/ FieldFormatter/ Condition/ HideOnRole.php, line 58
Class
- HideOnRole
- The plugin for check empty fields.
Namespace
Drupal\fico\Plugin\Field\FieldFormatter\ConditionCode
public function summary($settings) {
$roles = [];
foreach (Role::loadMultiple() as $role) {
if (in_array($role
->id(), $settings['settings']['roles'])) {
$roles[] = $role
->label();
}
}
return t("Condition: %condition (%settings)", [
"%condition" => t('Hide when current user has role'),
'%settings' => implode(', ', $roles),
]);
}