You are here

public function UserRole::summary in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 core/modules/user/src/Plugin/Condition/UserRole.php \Drupal\user\Plugin\Condition\UserRole::summary()

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

Overrides ConditionInterface::summary

File

core/modules/user/src/Plugin/Condition/UserRole.php, line 61
Contains \Drupal\user\Plugin\Condition\UserRole.

Class

UserRole
Provides a 'User Role' condition.

Namespace

Drupal\user\Plugin\Condition

Code

public function summary() {

  // Use the role labels. They will be sanitized below.
  $roles = array_intersect_key(user_role_names(), $this->configuration['roles']);
  if (count($roles) > 1) {
    $roles = implode(', ', $roles);
  }
  else {
    $roles = reset($roles);
  }
  if (!empty($this->configuration['negate'])) {
    return $this
      ->t('The user is not a member of @roles', array(
      '@roles' => $roles,
    ));
  }
  else {
    return $this
      ->t('The user is a member of @roles', array(
      '@roles' => $roles,
    ));
  }
}