Drupal Version
9.2.10
Domain module version
8.x-1.0-beta6
Expected Behavior
Domain condition should actually derive the domain if there is no `domain` context value available.
Actual Behavior
The following exception is thrown, since the existence of the value is checked by `getContextValue()` (see: https://git.drupalcode.org/project/domain/-/blob/8.x-1.x/domain/src/Plug...) which will throw a exception if the value is absent.
Drupal\Component\Plugin\Exception\ContextException: The 'entity:domain' context is required and not present. in Drupal\Core\Plugin\Context\Context->getContextValue() (line 73 of core/lib/Drupal/Core/Plugin/Context/Context.php).
Steps to reproduce
Not sure when the domain context value should actually be present. I noticed that it is absent when trying to evaluate the condition in a `html` preprocess with the following code:
$block = $this->entityTypeManager->getStorage('block')->load('BLOCK_ID');
if (!$block) {
return $variables;
}
$visibilityConditions = $block->getVisibilityConditions();
if (!is_iterable($visibilityConditions)) {
return $variables;
}
$visible = TRUE;
foreach ($visibilityConditions as $visibilityCondition) {
if ($visibilityCondition->evaluate()) {
continue;
}
$visible = FALSE;
}
Issue fork domain-3254743
Show commands
Start within a Git clone of the project using the version control instructions.
Or, if you do not have SSH keys set up on git.drupalcode.org:
Comments
Comment #3
nvakenComment #4
agentrickardThis looks like a cleaner (or more updated version of the current code).
It also looks like domain/tests/src/Functional/DomainContextTest.php is unfinished. That's where we should probably test this.
Comment #5
mably commentedIs it still a problem? It it is the case, can we have a MR on 2.0.x please?
Comment #6
mably commentedRebased.
Comment #7
mably commentedComment #9
mably commented