From 5acb9b357f0bf23490878204ecfaa88c1a012ca6 Mon Sep 17 00:00:00 2001 From: Jordan Dukart <jordan@discoverygarden.ca> Date: Tue, 7 Mar 2023 15:18:40 +0000 Subject: [PATCH] Reset contexts before evaluation. --- src/IslandoraContextManager.php | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/src/IslandoraContextManager.php b/src/IslandoraContextManager.php index 801e3253..aa286480 100644 --- a/src/IslandoraContextManager.php +++ b/src/IslandoraContextManager.php @@ -13,6 +13,14 @@ use Drupal\Component\Plugin\Exception\ContextException; */ class IslandoraContextManager extends ContextManager { + /** + * Allow the contexts to be reset before evaluation. + */ + protected function resetContextEvaluation() { + $this->contexts = []; + $this->contextConditionsEvaluated = FALSE; + } + /** * Evaluate all context conditions. * @@ -22,7 +30,9 @@ class IslandoraContextManager extends ContextManager { public function evaluateContexts(array $provided = []) { $this->activeContexts = []; - + // XXX: Ensure that no earlier executed contexts in the request are still + // present. + $this->resetContextEvaluation(); /** @var \Drupal\context\ContextInterface $context */ foreach ($this->getContexts() as $context) { if ($this->evaluateContextConditions($context, $provided) && !$context->disabled()) {