function 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 84  
Class
- UserRole
 - Provides a 'User Role' condition.
 
Namespace
Drupal\user\Plugin\ConditionCode
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());
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.