public function ContextManager::evaluateContextConditions in Context 8.4
Same name and namespace in other branches
- 8 src/ContextManager.php \Drupal\context\ContextManager::evaluateContextConditions()
- 8.0 src/ContextManager.php \Drupal\context\ContextManager::evaluateContextConditions()
Evaluate a contexts conditions.
Parameters
\Drupal\context\Entity\ContextInterface $context: The context to evaluate conditions for.
Return value
bool Whether these conditions grant or deny access.
1 call to ContextManager::evaluateContextConditions()
- ContextManager::evaluateContexts in src/
ContextManager.php - Evaluate all context conditions.
File
- src/
ContextManager.php, line 330
Class
- ContextManager
- This is the manager service for the context module.
Namespace
Drupal\contextCode
public function evaluateContextConditions(ContextInterface $context) {
$conditions = $context
->getConditions();
// Apply context to any context aware conditions.
// Abort if the application of contexts has been unsuccessful
// similarly to BlockAccessControlHandler::checkAccess().
if (!$this
->applyContexts($conditions)) {
return FALSE;
}
// 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);
}