comparison 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
comparison
equal deleted inserted replaced
15:e200cb7efeb3 16:c2387f117808
1 <?php 1 <?php
2 2
3 namespace Drupal\user\Plugin\migrate; 3 namespace Drupal\user\Plugin\migrate;
4 4
5 use Drupal\migrate\Exception\RequirementsException; 5 use Drupal\migrate\Exception\RequirementsException;
6 use Drupal\migrate\MigrateExecutable;
7 use Drupal\migrate\MigrateSkipRowException;
6 use Drupal\migrate\Plugin\Migration; 8 use Drupal\migrate\Plugin\Migration;
7 9
8 /** 10 /**
9 * Plugin class for user migrations dealing with profile values. 11 * Plugin class for user migrations dealing with profile values.
10 */ 12 */
29 ] + $this->source; 31 ] + $this->source;
30 $definition['destination']['plugin'] = 'null'; 32 $definition['destination']['plugin'] = 'null';
31 $definition['idMap']['plugin'] = 'null'; 33 $definition['idMap']['plugin'] = 'null';
32 try { 34 try {
33 $profile_field_migration = $this->migrationPluginManager->createStubMigration($definition); 35 $profile_field_migration = $this->migrationPluginManager->createStubMigration($definition);
36 $migrate_executable = new MigrateExecutable($profile_field_migration);
34 $source_plugin = $profile_field_migration->getSourcePlugin(); 37 $source_plugin = $profile_field_migration->getSourcePlugin();
35 $source_plugin->checkRequirements(); 38 $source_plugin->checkRequirements();
36 foreach ($source_plugin as $row) { 39 foreach ($source_plugin as $row) {
37 $name = $row->getSourceProperty('name'); 40 $name = $row->getSourceProperty('name');
38 $this->process[$name] = $name; 41 $fid = $row->getSourceProperty('fid');
42 // The user profile field name can be greater than 32 characters. Use
43 // the migrated profile field name in the process pipeline.
44 $configuration =
45 [
46 'migration' => 'user_profile_field',
47 'source_ids' => $fid,
48 ];
49 $plugin = $this->processPluginManager->createInstance('migration_lookup', $configuration, $profile_field_migration);
50 $new_value = $plugin->transform($fid, $migrate_executable, $row, 'tmp');
51 if (isset($new_value[1])) {
52 // Set the destination to the migrated profile field name.
53 $this->process[$new_value[1]] = $name;
54 }
55 else {
56 throw new MigrateSkipRowException("Can't migrate source field $name.");
57 }
39 } 58 }
40 } 59 }
41 catch (RequirementsException $e) { 60 catch (RequirementsException $e) {
42 // The checkRequirements() call will fail when the profile module does 61 // The checkRequirements() call will fail when the profile module does
43 // not exist on the source site. 62 // not exist on the source site.