diff --git a/src/Plugin/Condition/Term.php b/src/Plugin/Condition/Term.php index 1935a69..aa4b6f9 100644 --- a/src/Plugin/Condition/Term.php +++ b/src/Plugin/Condition/Term.php @@ -18,7 +18,7 @@ use Drupal\Core\Plugin\Context\ContextDefinition; * id = "term", * label = @Translation("Term"), * context = { -* "node" = @ContextDefinition("entity:node", required = TRUE , label = @Translation("node")) +* "node" = @ContextDefinition("entity:node", required = FALSE , label = @Translation("node")) * } * ) * @@ -88,6 +88,11 @@ class Term extends ConditionPluginBase { $node = $this->getContextValue('node'); + // Not in a node context. + if (!$node) { + return FALSE; + } + foreach ($node->referencedEntities() as $referenced_entity) { if ($referenced_entity->getEntityTypeId() == 'taxonomy_term' && $referenced_entity->id() == $this->configuration['tid']) {