Browse Source

Implement solution for drupal issues 3089660 and 3045666

MNPALS-2.x
Lucas van Schaik 2 years ago committed by Rosie Le Faive
parent
commit
709938cf29
  1. 12
      src/IslandoraContextManager.php

12
src/IslandoraContextManager.php

@ -60,7 +60,11 @@ class IslandoraContextManager extends ContextManager {
$conditions = $context->getConditions(); $conditions = $context->getConditions();
// Apply context to any context aware conditions. // 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. // Set the logic to use when validating the conditions.
$logic = $context->requiresAllConditions() $logic = $context->requiresAllConditions()
@ -88,6 +92,7 @@ class IslandoraContextManager extends ContextManager {
* TRUE if conditions pass * TRUE if conditions pass
*/ */
protected function applyContexts(ConditionPluginCollection &$conditions, array $provided = []) { protected function applyContexts(ConditionPluginCollection &$conditions, array $provided = []) {
$passed = FALSE;
foreach ($conditions as $condition) { foreach ($conditions as $condition) {
if ($condition instanceof ContextAwarePluginInterface) { if ($condition instanceof ContextAwarePluginInterface) {
try { try {
@ -98,14 +103,15 @@ class IslandoraContextManager extends ContextManager {
$contexts = $provided; $contexts = $provided;
} }
$this->contextHandler->applyContextMapping($condition, $contexts); $this->contextHandler->applyContextMapping($condition, $contexts);
$passed = TRUE;
} }
catch (ContextException $e) { catch (ContextException $e) {
return FALSE; continue;
} }
} }
} }
return TRUE; return $passed;
} }
} }

Loading…
Cancel
Save