You are here

public function UserRole::summary in RNG - Events and Registrations 8

Same name and namespace in other branches
  1. 8.2 src/Plugin/Condition/UserRole.php \Drupal\rng\Plugin\Condition\UserRole::summary()
  2. 3.x src/Plugin/Condition/UserRole.php \Drupal\rng\Plugin\Condition\UserRole::summary()

Provides a human readable summary of the condition's configuration.

Overrides UserRole::summary

File

src/Plugin/Condition/UserRole.php, line 42

Class

UserRole
Provides a user role condition where all roles are matched.

Namespace

Drupal\rng\Plugin\Condition

Code

public function summary() {

  // Ensure roles in configuration are still existing or valid roles.
  $roles = array_intersect_key($this
    ->getRoles(), $this->configuration['roles']);
  if (!count($roles)) {
    return $this
      ->t('Any registered user');
  }
  return $this
    ->t(empty($this->configuration['negate']) ? 'User is a member of @roles' : 'User is not a member of @roles', [
    '@roles' => count($roles) > 1 ? implode(' and ', $roles) : reset($roles),
  ]);
}