function EntityBundle::evaluate

Same name in other branches
  1. 10 core/lib/Drupal/Core/Entity/Plugin/Condition/EntityBundle.php \Drupal\Core\Entity\Plugin\Condition\EntityBundle::evaluate()
  2. 11.x core/lib/Drupal/Core/Entity/Plugin/Condition/EntityBundle.php \Drupal\Core\Entity\Plugin\Condition\EntityBundle::evaluate()

Overrides ConditionInterface::evaluate

File

core/lib/Drupal/Core/Entity/Plugin/Condition/EntityBundle.php, line 85

Class

EntityBundle
Provides the 'Entity Bundle' condition.

Namespace

Drupal\Core\Entity\Plugin\Condition

Code

public function evaluate() {
    // Returns true if no bundles are selected and negate option is disabled.
    if (empty($this->configuration['bundles']) && !$this->isNegated()) {
        return TRUE;
    }
    
    /** @var \Drupal\Core\Entity\ContentEntityInterface $entity */
    $entity = $this->getContextValue($this->getDerivativeId());
    return !empty($this->configuration['bundles'][$entity->bundle()]);
}

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