3 namespace Drupal\user\Plugin\migrate;
5 use Drupal\migrate\Exception\RequirementsException;
6 use Drupal\migrate\MigrateExecutable;
7 use Drupal\migrate\MigrateSkipRowException;
8 use Drupal\migrate\Plugin\Migration;
11 * Plugin class for user migrations dealing with profile values.
13 class ProfileValues extends Migration {
16 * Flag determining whether the process plugin has been initialized.
20 protected $init = FALSE;
25 public function getProcess() {
28 $definition['source'] = [
29 'plugin' => 'profile_field',
32 $definition['destination']['plugin'] = 'null';
33 $definition['idMap']['plugin'] = 'null';
35 $profile_field_migration = $this->migrationPluginManager->createStubMigration($definition);
36 $migrate_executable = new MigrateExecutable($profile_field_migration);
37 $source_plugin = $profile_field_migration->getSourcePlugin();
38 $source_plugin->checkRequirements();
39 foreach ($source_plugin as $row) {
40 $name = $row->getSourceProperty('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.
46 'migration' => 'user_profile_field',
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;
56 throw new MigrateSkipRowException("Can't migrate source field $name.");
60 catch (RequirementsException $e) {
61 // The checkRequirements() call will fail when the profile module does
62 // not exist on the source site.
65 return parent::getProcess();