From 78c3f76b0c21330a0806f6a9dcd7d564835d210f Mon Sep 17 00:00:00 2001 From: Noel Chiasson Date: Wed, 26 Jun 2024 15:26:27 -0300 Subject: [PATCH] Bypasses condition evaluation if retrieved identifier doesn't exist --- src/Plugin/Condition/EntityHasIdentifier.php | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/src/Plugin/Condition/EntityHasIdentifier.php b/src/Plugin/Condition/EntityHasIdentifier.php index 8652220..4991d48 100644 --- a/src/Plugin/Condition/EntityHasIdentifier.php +++ b/src/Plugin/Condition/EntityHasIdentifier.php @@ -110,11 +110,13 @@ public function evaluate(): bool { $entity = $this->getContextValue('entity'); if ($entity instanceof FieldableEntityInterface) { $identifier = $this->entityTypeManager->getStorage('dgiactions_identifier')->load($this->configuration['identifier']); - $field = $identifier->get('field'); - $entity_type = $identifier->get('entity'); - $bundle = $identifier->get('bundle'); - if (!empty($field) && $entity->hasField($field) && $entity->getEntityTypeId() == $entity_type && $entity->bundle() == $bundle) { - return !$entity->get($field)->isEmpty(); + if ($identifier) { + $field = $identifier->get('field'); + $entity_type = $identifier->get('entity'); + $bundle = $identifier->get('bundle'); + if (!empty($field) && $entity->hasField($field) && $entity->getEntityTypeId() == $entity_type && $entity->bundle() == $bundle) { + return !$entity->get($field)->isEmpty(); + } } } return FALSE;