Mercurial > hg > isophonics-drupal-site
annotate core/modules/user/src/Plugin/migrate/ProfileValues.php @ 0:4c8ae668cc8c
Initial import (non-working)
author | Chris Cannam |
---|---|
date | Wed, 29 Nov 2017 16:09:58 +0000 |
parents | |
children | 1fec387a4317 |
rev | line source |
---|---|
Chris@0 | 1 <?php |
Chris@0 | 2 |
Chris@0 | 3 namespace Drupal\user\Plugin\migrate; |
Chris@0 | 4 |
Chris@0 | 5 use Drupal\migrate\Exception\RequirementsException; |
Chris@0 | 6 use Drupal\migrate\Plugin\Migration; |
Chris@0 | 7 |
Chris@0 | 8 /** |
Chris@0 | 9 * Plugin class for user migrations dealing with profile values. |
Chris@0 | 10 */ |
Chris@0 | 11 class ProfileValues extends Migration { |
Chris@0 | 12 |
Chris@0 | 13 /** |
Chris@0 | 14 * Flag determining whether the process plugin has been initialized. |
Chris@0 | 15 * |
Chris@0 | 16 * @var bool |
Chris@0 | 17 */ |
Chris@0 | 18 protected $init = FALSE; |
Chris@0 | 19 |
Chris@0 | 20 /** |
Chris@0 | 21 * {@inheritdoc} |
Chris@0 | 22 */ |
Chris@0 | 23 public function getProcess() { |
Chris@0 | 24 if (!$this->init) { |
Chris@0 | 25 $this->init = TRUE; |
Chris@0 | 26 $definition['source'] = [ |
Chris@0 | 27 'plugin' => 'profile_field', |
Chris@0 | 28 'ignore_map' => TRUE, |
Chris@0 | 29 ] + $this->source; |
Chris@0 | 30 $definition['destination']['plugin'] = 'null'; |
Chris@0 | 31 try { |
Chris@0 | 32 $profile_field_migration = $this->migrationPluginManager->createStubMigration($definition); |
Chris@0 | 33 $source_plugin = $profile_field_migration->getSourcePlugin(); |
Chris@0 | 34 $source_plugin->checkRequirements(); |
Chris@0 | 35 foreach ($source_plugin as $row) { |
Chris@0 | 36 $name = $row->getSourceProperty('name'); |
Chris@0 | 37 $this->process[$name] = $name; |
Chris@0 | 38 } |
Chris@0 | 39 } |
Chris@0 | 40 catch (RequirementsException $e) { |
Chris@0 | 41 // The checkRequirements() call will fail when the profile module does |
Chris@0 | 42 // not exist on the source site. |
Chris@0 | 43 } |
Chris@0 | 44 } |
Chris@0 | 45 return parent::getProcess(); |
Chris@0 | 46 } |
Chris@0 | 47 |
Chris@0 | 48 } |