function EntityBundle::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

src/Plugin/Condition/EntityBundle.php, line 106

Class

EntityBundle
Provides a 'Entity Bundle' condition.

Namespace

Drupal\ctools\Plugin\Condition

Code

public function evaluate() {
  if (empty($this->configuration['bundles']) && !$this->isNegated()) {
    return TRUE;
  }
  /** @var \Drupal\Core\Entity\ContentEntityInterface $entity */
  $entity = $this->getContextValue($this->bundleOf
    ->id());
  if (!$entity instanceof ContentEntityInterface) {
    return TRUE;
  }
  return !empty($this->configuration['bundles'][$entity->bundle()]);
}