Skip to content

Commit

Permalink
Reset contexts before evaluation. (#932)
Browse files Browse the repository at this point in the history
* Reset contexts before evaluation.
* Only reset when Islandora's ContextProviders are being used.
  • Loading branch information
jordandukart authored Mar 13, 2023
1 parent db85922 commit c721f9b
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion src/IslandoraContextManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,14 @@
*/
class IslandoraContextManager extends ContextManager {

/**
* Allow the contexts to be reset before evaluation.
*/
protected function resetContextEvaluation() {
$this->contexts = [];
$this->contextConditionsEvaluated = FALSE;
}

/**
* Evaluate all context conditions.
*
Expand All @@ -22,7 +30,11 @@ class IslandoraContextManager extends ContextManager {
public function evaluateContexts(array $provided = []) {

$this->activeContexts = [];

// XXX: Ensure that no earlier executed contexts in the request are still
// present when being triggered via Islandora's ContextProviders.
if (!empty($provided)) {
$this->resetContextEvaluation();
}
/** @var \Drupal\context\ContextInterface $context */
foreach ($this->getContexts() as $context) {
if ($this->evaluateContextConditions($context, $provided) && !$context->disabled()) {
Expand Down

0 comments on commit c721f9b

Please sign in to comment.