function Entity::validateEntity

Same name in other branches
  1. 9 core/modules/views/src/Plugin/views/argument_validator/Entity.php \Drupal\views\Plugin\views\argument_validator\Entity::validateEntity()
  2. 8.9.x core/modules/views/src/Plugin/views/argument_validator/Entity.php \Drupal\views\Plugin\views\argument_validator\Entity::validateEntity()
  3. 11.x core/modules/views/src/Plugin/views/argument_validator/Entity.php \Drupal\views\Plugin\views\argument_validator\Entity::validateEntity()

Validates an individual entity against class access settings.

Parameters

\Drupal\Core\Entity\EntityInterface $entity: The entity.

Return value

bool True if validated.

2 calls to Entity::validateEntity()
Entity::validateArgument in core/modules/views/src/Plugin/views/argument_validator/Entity.php
Performs validation for a given argument.
TermName::validateArgument in core/modules/taxonomy/src/Plugin/views/argument_validator/TermName.php
Performs validation for a given argument.
1 method overrides Entity::validateEntity()
User::validateEntity in core/modules/user/src/Plugin/views/argument_validator/User.php
Validates an individual entity against class access settings.

File

core/modules/views/src/Plugin/views/argument_validator/Entity.php, line 216

Class

Entity
Defines an argument validator plugin for each entity type.

Namespace

Drupal\views\Plugin\views\argument_validator

Code

protected function validateEntity(EntityInterface $entity) {
    // If access restricted by entity operation.
    if ($this->options['access'] && !$entity->access($this->options['operation'])) {
        return FALSE;
    }
    // If restricted by bundle.
    $bundles = $this->options['bundles'];
    if (!empty($bundles) && empty($bundles[$entity->bundle()])) {
        return FALSE;
    }
    return TRUE;
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.