diff --git a/core/modules/migrate/src/Entity/Migration.php b/core/modules/migrate/src/Entity/Migration.php index ba563f1..3357205 100644 --- a/core/modules/migrate/src/Entity/Migration.php +++ b/core/modules/migrate/src/Entity/Migration.php @@ -406,6 +406,13 @@ public function setProcess(array $process) { /** * {@inheritdoc} */ + public function setProcessOfProperty($field_name, $process) { + $this->process[$field_name] = $process; + } + + /** + * {@inheritdoc} + */ public function getSystemOfRecord() { return $this->systemOfRecord; } diff --git a/core/modules/migrate/src/Entity/MigrationInterface.php b/core/modules/migrate/src/Entity/MigrationInterface.php index 09cc770..76851ac 100644 --- a/core/modules/migrate/src/Entity/MigrationInterface.php +++ b/core/modules/migrate/src/Entity/MigrationInterface.php @@ -198,6 +198,18 @@ public function getProcess(); public function setProcess(array $process); /** + * Set the process for an individual destination field. + * + * @param string $field_name + * The field name of which to set the process. + * @param $process + * An array of process data. + * + * @see Drupal\migrate_drupal\Plugin\migrate\load\LoadEntity::processLinkField(). + */ + public function setProcessOfProperty($field_name, $process); + + /** * Get the current system of record of the migration. * * @return string diff --git a/core/modules/migrate_drupal/src/Plugin/migrate/load/LoadEntity.php b/core/modules/migrate_drupal/src/Plugin/migrate/load/LoadEntity.php index ea7f75e..73c8519 100644 --- a/core/modules/migrate_drupal/src/Plugin/migrate/load/LoadEntity.php +++ b/core/modules/migrate_drupal/src/Plugin/migrate/load/LoadEntity.php @@ -132,9 +132,7 @@ public function loadMultiple(EntityStorageInterface $storage, array $sub_ids = N $this->processTextField($field_name, $data, $migration); break; default: - $process = $migration->getProcess(); - $process[$field_name] = $field_name; - $migration->setProcess($process); + $migration->setProcessOfProperty($field_name, $field_name); } } } @@ -168,12 +166,10 @@ protected function processTextField($field_name, $field_data, MigrationInterface $value_key = $field_data['db_storage'] ? $field_name : "$field_name/value"; $format_key = $field_data['db_storage'] ? $field_name . '_format' : "$field_name/format" ; - $process = $migration->getProcess(); - - $process["$field_name/value"] = $value_key; + $migration->setProcessOfProperty("$field_name/value", $value_key); // See d6_user, signature_format for an example of the YAML that // represents this process array. - $process["$field_name/format"] = [ + $process = [ [ 'plugin' => 'static_map', 'bypass' => TRUE, @@ -188,7 +184,7 @@ protected function processTextField($field_name, $field_data, MigrationInterface ], ]; - $migration->setProcess($process); + $migration->setProcessOfProperty("$field_name/format", $process); } /** @@ -202,8 +198,7 @@ protected function processTextField($field_name, $field_data, MigrationInterface * The migration entity. */ protected function processFileField($field_name, $field_data, MigrationInterface $migration) { - $process = $migration->getProcess(); - $process[$field_name] = [ + $process = [ 'plugin' => 'd6_cck_file', 'source' => [ $field_name, @@ -211,7 +206,7 @@ protected function processFileField($field_name, $field_data, MigrationInterface $field_name . '_data', ], ]; - $migration->setProcess($process); + $migration->setProcessOfProperty($field_name, $process); } /** @@ -227,8 +222,7 @@ protected function processFileField($field_name, $field_data, MigrationInterface protected function processLinkField($field_name, $field_data, MigrationInterface $migration) { // Specifically process the link field until core is fixed. // @see https://www.drupal.org/node/2235457 - $process = $migration->getProcess(); - $process[$field_name] = [ + $process = [ 'plugin' => 'd6_cck_link', 'source' => [ $field_name, @@ -236,7 +230,7 @@ protected function processLinkField($field_name, $field_data, MigrationInterface $field_name . '_attributes', ], ]; - $migration->setProcess($process); + $migration->setProcessOfProperty($field_name, $process); } /**