Browse Source

Reset contexts before evaluation. (#932)

* Reset contexts before evaluation.
* Only reset when Islandora's ContextProviders are being used.
pull/935/head
Jordan Dukart 2 years ago committed by GitHub
parent
commit
c721f9ba07
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 14
      src/IslandoraContextManager.php

14
src/IslandoraContextManager.php

@ -13,6 +13,14 @@ use Drupal\Component\Plugin\Exception\ContextException;
*/ */
class IslandoraContextManager extends ContextManager { class IslandoraContextManager extends ContextManager {
/**
* Allow the contexts to be reset before evaluation.
*/
protected function resetContextEvaluation() {
$this->contexts = [];
$this->contextConditionsEvaluated = FALSE;
}
/** /**
* Evaluate all context conditions. * Evaluate all context conditions.
* *
@ -22,7 +30,11 @@ class IslandoraContextManager extends ContextManager {
public function evaluateContexts(array $provided = []) { public function evaluateContexts(array $provided = []) {
$this->activeContexts = []; $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 */ /** @var \Drupal\context\ContextInterface $context */
foreach ($this->getContexts() as $context) { foreach ($this->getContexts() as $context) {
if ($this->evaluateContextConditions($context, $provided) && !$context->disabled()) { if ($this->evaluateContextConditions($context, $provided) && !$context->disabled()) {

Loading…
Cancel
Save