Mercurial > hg > isophonics-drupal-site
comparison core/modules/user/src/Plugin/migrate/ProfileValues.php @ 17:129ea1e6d783
Update, including to Drupal core 8.6.10
author | Chris Cannam |
---|---|
date | Thu, 28 Feb 2019 13:21:36 +0000 |
parents | c2387f117808 |
children |
comparison
equal
deleted
inserted
replaced
16:c2387f117808 | 17:129ea1e6d783 |
---|---|
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; | 6 use Drupal\migrate\MigrateExecutable; |
7 use Drupal\migrate\MigrateSkipRowException; | |
8 use Drupal\migrate\Plugin\Migration; | 7 use Drupal\migrate\Plugin\Migration; |
9 | 8 |
10 /** | 9 /** |
11 * Plugin class for user migrations dealing with profile values. | 10 * Plugin class for user migrations dealing with profile values. |
12 */ | 11 */ |
30 'ignore_map' => TRUE, | 29 'ignore_map' => TRUE, |
31 ] + $this->source; | 30 ] + $this->source; |
32 $definition['destination']['plugin'] = 'null'; | 31 $definition['destination']['plugin'] = 'null'; |
33 $definition['idMap']['plugin'] = 'null'; | 32 $definition['idMap']['plugin'] = 'null'; |
34 try { | 33 try { |
34 $this->checkRequirements(); | |
35 $profile_field_migration = $this->migrationPluginManager->createStubMigration($definition); | 35 $profile_field_migration = $this->migrationPluginManager->createStubMigration($definition); |
36 $migrate_executable = new MigrateExecutable($profile_field_migration); | 36 $migrate_executable = new MigrateExecutable($profile_field_migration); |
37 $source_plugin = $profile_field_migration->getSourcePlugin(); | 37 $source_plugin = $profile_field_migration->getSourcePlugin(); |
38 $source_plugin->checkRequirements(); | 38 $source_plugin->checkRequirements(); |
39 foreach ($source_plugin as $row) { | 39 foreach ($source_plugin as $row) { |
43 // the migrated profile field name in the process pipeline. | 43 // the migrated profile field name in the process pipeline. |
44 $configuration = | 44 $configuration = |
45 [ | 45 [ |
46 'migration' => 'user_profile_field', | 46 'migration' => 'user_profile_field', |
47 'source_ids' => $fid, | 47 'source_ids' => $fid, |
48 'no_stub' => TRUE, | |
48 ]; | 49 ]; |
49 $plugin = $this->processPluginManager->createInstance('migration_lookup', $configuration, $profile_field_migration); | 50 $plugin = $this->processPluginManager->createInstance('migration_lookup', $configuration, $profile_field_migration); |
50 $new_value = $plugin->transform($fid, $migrate_executable, $row, 'tmp'); | 51 $new_value = $plugin->transform($fid, $migrate_executable, $row, 'tmp'); |
51 if (isset($new_value[1])) { | 52 if (isset($new_value[1])) { |
52 // Set the destination to the migrated profile field name. | 53 // Set the destination to the migrated profile field name. |
53 $this->process[$new_value[1]] = $name; | 54 $this->process[$new_value[1]] = $name; |
54 } | 55 } |
55 else { | |
56 throw new MigrateSkipRowException("Can't migrate source field $name."); | |
57 } | |
58 } | 56 } |
59 } | 57 } |
60 catch (RequirementsException $e) { | 58 catch (RequirementsException $e) { |
61 // The checkRequirements() call will fail when the profile module does | 59 // The checkRequirements() call will fail when the profile module does |
62 // not exist on the source site. | 60 // not exist on the source site, or if the required migrations have not |
61 // yet run. | |
63 } | 62 } |
64 } | 63 } |
65 return parent::getProcess(); | 64 return parent::getProcess(); |
66 } | 65 } |
67 | 66 |