Loading src/Plugin/Condition/ContextAll.php +7 −4 Original line number Diff line number Diff line Loading @@ -156,10 +156,13 @@ class ContextAll extends ConditionPluginBase implements ContainerFactoryPluginIn // Now handle required contexts. foreach ($required_contexts as $name) { /** @var \Drupal\context\ContextInterface $required_context */ if ($required_context = $this->contextManager->getContext($name)) { if (!$this->contextManager->evaluateContextConditions($required_context) && !$required_context->disabled()) { $required_context = $this->contextManager->getContext($name); // A non-existent context can never be active. if (!isset($required_context)) { return FALSE; } if (!$this->contextManager->evaluateContextConditions($required_context) && !$required_context->disabled()) { return FALSE; } } Loading tests/src/Kernel/ContextAllAnyTest.php +7 −0 Original line number Diff line number Diff line Loading @@ -146,6 +146,13 @@ class ContextAllAnyTest extends KernelTestBase { $this->assertTrue($condition->evaluate(), 'All contexts are active'); $this->assertEquals($condition->summary(), 'Return true on the basis of other active contexts: ~another_context, test', 'Context applied.'); // Test that a non-existent context evaluates to false. $condition->setConfig('values', 'does_not_exist'); $this->assertFalse($condition->evaluate(), 'All contexts are not active'); $condition->setConfig('values', "another_context\r\ndoes_not_exist"); $this->assertFalse($condition->evaluate(), 'All contexts are not active'); } /** Loading Loading
src/Plugin/Condition/ContextAll.php +7 −4 Original line number Diff line number Diff line Loading @@ -156,10 +156,13 @@ class ContextAll extends ConditionPluginBase implements ContainerFactoryPluginIn // Now handle required contexts. foreach ($required_contexts as $name) { /** @var \Drupal\context\ContextInterface $required_context */ if ($required_context = $this->contextManager->getContext($name)) { if (!$this->contextManager->evaluateContextConditions($required_context) && !$required_context->disabled()) { $required_context = $this->contextManager->getContext($name); // A non-existent context can never be active. if (!isset($required_context)) { return FALSE; } if (!$this->contextManager->evaluateContextConditions($required_context) && !$required_context->disabled()) { return FALSE; } } Loading
tests/src/Kernel/ContextAllAnyTest.php +7 −0 Original line number Diff line number Diff line Loading @@ -146,6 +146,13 @@ class ContextAllAnyTest extends KernelTestBase { $this->assertTrue($condition->evaluate(), 'All contexts are active'); $this->assertEquals($condition->summary(), 'Return true on the basis of other active contexts: ~another_context, test', 'Context applied.'); // Test that a non-existent context evaluates to false. $condition->setConfig('values', 'does_not_exist'); $this->assertFalse($condition->evaluate(), 'All contexts are not active'); $condition->setConfig('values', "another_context\r\ndoes_not_exist"); $this->assertFalse($condition->evaluate(), 'All contexts are not active'); } /** Loading