Skip to content

Commit

Permalink
Merge pull request #931 from LeidenUniversityLibrary/fix_documentatio…
Browse files Browse the repository at this point in the history
…n_2069

Fix for documentation 2069
  • Loading branch information
jordandukart authored Mar 14, 2023
2 parents bb06d81 + d041ec3 commit e366da3
Showing 1 changed file with 15 additions and 3 deletions.
18 changes: 15 additions & 3 deletions src/IslandoraContextManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,11 @@ public function evaluateContextConditions(ContextInterface $context, array $prov
$conditions = $context->getConditions();

// Apply context to any context aware conditions.
$this->applyContexts($conditions, $provided);
// Abort if the application of contexts has been unsuccessful
// similarly to BlockAccessControlHandler::checkAccess().
if (!$this->applyContexts($conditions, $provided)) {
return FALSE;
}

// Set the logic to use when validating the conditions.
$logic = $context->requiresAllConditions()
Expand Down Expand Up @@ -88,6 +92,13 @@ public function evaluateContextConditions(ContextInterface $context, array $prov
* TRUE if conditions pass
*/
protected function applyContexts(ConditionPluginCollection &$conditions, array $provided = []) {

// If no contexts to check, the return should be TRUE.
// For example, empty is the same as sitewide condition.
if (count($conditions) === 0) {
return TRUE;
}
$passed = FALSE;
foreach ($conditions as $condition) {
if ($condition instanceof ContextAwarePluginInterface) {
try {
Expand All @@ -98,14 +109,15 @@ protected function applyContexts(ConditionPluginCollection &$conditions, array $
$contexts = $provided;
}
$this->contextHandler->applyContextMapping($condition, $contexts);
$passed = TRUE;
}
catch (ContextException $e) {
return FALSE;
continue;
}
}
}

return TRUE;
return $passed;
}

}

0 comments on commit e366da3

Please sign in to comment.