protected function ConditionAccessResolverTrait::resolveConditions in Zircon Profile 8
Same name and namespace in other branches
- 8.0 core/lib/Drupal/Core/Condition/ConditionAccessResolverTrait.php \Drupal\Core\Condition\ConditionAccessResolverTrait::resolveConditions()
Resolves the given conditions based on the condition logic ('and'/'or').
Parameters
\Drupal\Core\Condition\ConditionInterface[] $conditions: A set of conditions.
string $condition_logic: The logic used to compute access, either 'and' or 'or'.
Return value
bool Whether these conditions grant or deny access.
1 call to ConditionAccessResolverTrait::resolveConditions()
- BlockAccessControlHandler::checkAccess in core/
modules/ block/ src/ BlockAccessControlHandler.php - Performs access checks.
File
- core/
lib/ Drupal/ Core/ Condition/ ConditionAccessResolverTrait.php, line 28 - Contains \Drupal\Core\Condition\ConditionAccessResolverTrait.
Class
- ConditionAccessResolverTrait
- Resolves a set of conditions.
Namespace
Drupal\Core\ConditionCode
protected function resolveConditions($conditions, $condition_logic) {
foreach ($conditions as $condition) {
try {
$pass = $condition
->execute();
} catch (ContextException $e) {
// If a condition is missing context, consider that a fail.
$pass = FALSE;
}
// If a condition fails and all conditions were needed, deny access.
if (!$pass && $condition_logic == 'and') {
return FALSE;
}
elseif ($pass && $condition_logic == 'or') {
return TRUE;
}
}
// Return TRUE if logic was 'and', meaning all rules passed.
// Return FALSE if logic was 'or', meaning no rule passed.
return $condition_logic == 'and';
}