You are here

public function ContextManager::evaluateContextConditions in Context 8

Same name and namespace in other branches
  1. 8.4 src/ContextManager.php \Drupal\context\ContextManager::evaluateContextConditions()
  2. 8.0 src/ContextManager.php \Drupal\context\ContextManager::evaluateContextConditions()

Evaluate a contexts conditions.

Parameters

ContextInterface $context: The context to evaluate conditions for.

Return value

bool

1 call to ContextManager::evaluateContextConditions()
ContextManager::evaluateContexts in src/ContextManager.php
Evaluate all context conditions.

File

src/ContextManager.php, line 272

Class

ContextManager
This is the manager service for the context module and should not be confused with the built in contexts in Drupal.

Namespace

Drupal\context

Code

public function evaluateContextConditions(ContextInterface $context) {
  $conditions = $context
    ->getConditions();

  // Apply context to any context aware conditions.
  $this
    ->applyContexts($conditions);

  // Set the logic to use when validating the conditions.
  $logic = $context
    ->requiresAllConditions() ? 'and' : 'or';

  // Of there are no conditions then the context will be
  // applied as a site wide context.
  if (!count($conditions)) {
    $logic = 'and';
  }
  return $this
    ->resolveConditions($conditions, $logic);
}