You are here

public function NotConditionPluginBase::evaluate in Block Visibility Conditions 8

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/NotConditionPluginBase.php, line 158

Class

NotConditionPluginBase
Provides a 'Not {ContentEntityType}'-base condition.

Namespace

Drupal\block_visibility_conditions\Plugin\Condition

Code

public function evaluate() {

  // Check if a setting has been set.
  if (empty($this->configuration['bundles'])) {
    return TRUE;
  }

  // Check if we are dealing with a node.
  $entity = $this->routeMatch
    ->getParameter($this->contentEntityType
    ->getBundleOf());
  if (is_scalar($entity)) {
    $entity_storage = $this->entityTypeManager
      ->getStorage($this->contentEntityType
      ->getBundleOf());
    $entity = $entity_storage
      ->load($entity);
  }
  if (empty($entity)) {
    return TRUE;
  }
  return empty($this->configuration['bundles'][$entity
    ->bundle()]);
}