Skip to content

Commit

Permalink
Bypasses condition evaluation if retrieved identifier doesn't exist
Browse files Browse the repository at this point in the history
  • Loading branch information
nchiasson-dgi committed Jun 26, 2024
1 parent 5c4250d commit 78c3f76
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions src/Plugin/Condition/EntityHasIdentifier.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit 78c3f76

Please sign in to comment.