X-Git-Url: http://www.aleph1.co.uk/gitweb/?a=blobdiff_plain;ds=sidebyside;f=web%2Fmodules%2Fcontrib%2Fmigrate_plus%2Fsrc%2FPlugin%2Fmigrate%2Fprocess%2FEntityLookup.php;h=2ae0d07c1de2a438c830da55412a9c6618b2e7da;hb=059867c3f96750652c80f39e44c442a58c2549ee;hp=d02bb91244ca8e10143650b20132344ed7f95135;hpb=f8fc16ae6b862bef59baaad5d051dd37b7ff11b2;p=yaffs-website diff --git a/web/modules/contrib/migrate_plus/src/Plugin/migrate/process/EntityLookup.php b/web/modules/contrib/migrate_plus/src/Plugin/migrate/process/EntityLookup.php index d02bb9124..2ae0d07c1 100644 --- a/web/modules/contrib/migrate_plus/src/Plugin/migrate/process/EntityLookup.php +++ b/web/modules/contrib/migrate_plus/src/Plugin/migrate/process/EntityLookup.php @@ -2,6 +2,7 @@ namespace Drupal\migrate_plus\Plugin\migrate\process; +use Drupal\Core\Config\Entity\ConfigEntityInterface; use Drupal\Core\Entity\EntityManagerInterface; use Drupal\Core\Entity\EntityReferenceSelection\SelectionPluginManagerInterface; use Drupal\Core\Plugin\ContainerFactoryPluginInterface; @@ -152,6 +153,11 @@ class EntityLookup extends ProcessPluginBase implements ContainerFactoryPluginIn * {@inheritdoc} */ public function transform($value, MigrateExecutableInterface $migrateExecutable, Row $row, $destinationProperty) { + // If the source data is an empty array, return the same. + if (gettype($value) === 'array' && count($value) === 0) { + return []; + } + // In case of subfields ('field_reference/target_id'), extract the field // name only. $parts = explode('/', $destinationProperty); @@ -270,7 +276,8 @@ class EntityLookup extends ProcessPluginBase implements ContainerFactoryPluginIn if (!$ignoreCase) { // Returns the entity's identifier. foreach ($results as $k => $identifier) { - $result_value = $this->entityManager->getStorage($this->lookupEntityType)->load($identifier)->{$this->lookupValueKey}->value; + $entity = $this->entityManager->getStorage($this->lookupEntityType)->load($identifier); + $result_value = $entity instanceof ConfigEntityInterface ? $entity->get($this->lookupValueKey) : $entity->get($this->lookupValueKey)->value; if (($multiple && !in_array($result_value, $value, TRUE)) || (!$multiple && $result_value !== $value)) { unset($results[$k]); }