Skip to content
Snippets Groups Projects
Commit 70ef079f authored by Bec's avatar Bec Committed by Mike Ryan
Browse files

Issue #2782961 by becw: Allow returning multiple results from the entity_lookup process plugin

parent d9d4cad8
No related branches found
No related tags found
No related merge requests found
......@@ -226,25 +226,24 @@ class EntityLookup extends ProcessPluginBase implements ContainerFactoryPluginIn
return NULL;
}
if ($multiple && !empty($this->destinationProperty)) {
array_walk($results, function (&$value) {
$value = [$this->destinationProperty => $value];
});
return array_values($results);
}
// By default do a case-sensitive comparison.
if (!$ignoreCase) {
// Returns the entity's identifier.
foreach ($results as $identifier) {
if ($value === $this->entityManager->getStorage($this->lookupEntityType)->load($identifier)->{$this->lookupValueKey}->value) {
return $identifier;
foreach ($results as $k => $identifier) {
$result_value = $this->entityManager->getStorage($this->lookupEntityType)->load($identifier)->{$this->lookupValueKey}->value;
if (($multiple && !in_array($result_value, $value, TRUE)) || (!$multiple && $result_value !== $value)) {
unset($results[$k]);
}
}
}
return reset($results);
if ($multiple && !empty($this->destinationProperty)) {
array_walk($results, function (&$value) {
$value = [$this->destinationProperty => $value];
});
}
return $multiple ? array_values($results) : reset($results);
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment