diff core/modules/user/src/Plugin/migrate/ProfileValues.php @ 16:c2387f117808

Routine composer update
author Chris Cannam
date Tue, 10 Jul 2018 15:07:59 +0100
parents 1fec387a4317
children 129ea1e6d783
line wrap: on
line diff
--- a/core/modules/user/src/Plugin/migrate/ProfileValues.php	Thu Apr 26 11:26:54 2018 +0100
+++ b/core/modules/user/src/Plugin/migrate/ProfileValues.php	Tue Jul 10 15:07:59 2018 +0100
@@ -3,6 +3,8 @@
 namespace Drupal\user\Plugin\migrate;
 
 use Drupal\migrate\Exception\RequirementsException;
+use Drupal\migrate\MigrateExecutable;
+use Drupal\migrate\MigrateSkipRowException;
 use Drupal\migrate\Plugin\Migration;
 
 /**
@@ -31,11 +33,28 @@
       $definition['idMap']['plugin'] = 'null';
       try {
         $profile_field_migration = $this->migrationPluginManager->createStubMigration($definition);
+        $migrate_executable = new MigrateExecutable($profile_field_migration);
         $source_plugin = $profile_field_migration->getSourcePlugin();
         $source_plugin->checkRequirements();
         foreach ($source_plugin as $row) {
           $name = $row->getSourceProperty('name');
-          $this->process[$name] = $name;
+          $fid = $row->getSourceProperty('fid');
+          // The user profile field name can be greater than 32 characters. Use
+          // the migrated profile field name in the process pipeline.
+          $configuration =
+            [
+              'migration' => 'user_profile_field',
+              'source_ids' => $fid,
+            ];
+          $plugin = $this->processPluginManager->createInstance('migration_lookup', $configuration, $profile_field_migration);
+          $new_value = $plugin->transform($fid, $migrate_executable, $row, 'tmp');
+          if (isset($new_value[1])) {
+            // Set the destination to the migrated profile field name.
+            $this->process[$new_value[1]] = $name;
+          }
+          else {
+            throw new MigrateSkipRowException("Can't migrate source field $name.");
+          }
         }
       }
       catch (RequirementsException $e) {