You are here

public function UserRole::evaluate 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::evaluate()

Evaluates the condition and returns TRUE or FALSE accordingly.

Return value

bool TRUE if the condition has been met, FALSE otherwise.

Overrides ConditionInterface::evaluate

File

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

Class

UserRole
Provides a 'User Role' condition.

Namespace

Drupal\user\Plugin\Condition

Code

public function evaluate() {
  if (empty($this->configuration['roles']) && !$this
    ->isNegated()) {
    return TRUE;
  }
  $user = $this
    ->getContextValue('user');
  return (bool) array_intersect($this->configuration['roles'], $user
    ->getRoles());
}