You are here

protected function User::validateEntity in Zircon Profile 8.0

Same name and namespace in other branches
  1. 8 core/modules/user/src/Plugin/views/argument_validator/User.php \Drupal\user\Plugin\views\argument_validator\User::validateEntity()

Validates an individual entity against class access settings.

Parameters

\Drupal\Core\Entity\EntityInterface $entity:

Return value

bool True if validated.

Overrides Entity::validateEntity

1 call to User::validateEntity()
UserName::validateArgument in core/modules/user/src/Plugin/views/argument_validator/UserName.php

File

core/modules/user/src/Plugin/views/argument_validator/User.php, line 90
Contains \Drupal\user\Plugin\views\argument_validator\User.

Class

User
Validate whether an argument is a valid user.

Namespace

Drupal\user\Plugin\views\argument_validator

Code

protected function validateEntity(EntityInterface $entity) {

  /** @var \Drupal\user\UserInterface $entity */
  $role_check_success = TRUE;

  // See if we're filtering users based on roles.
  if (!empty($this->options['restrict_roles']) && !empty($this->options['roles'])) {
    $roles = $this->options['roles'];
    if (!(bool) array_intersect($entity
      ->getRoles(), $roles)) {
      $role_check_success = FALSE;
    }
  }
  return $role_check_success && parent::validateEntity($entity);
}