Mercurial > hg > isophonics-drupal-site
comparison core/modules/user/src/Plugin/migrate/User.php @ 0:4c8ae668cc8c
Initial import (non-working)
author | Chris Cannam |
---|---|
date | Wed, 29 Nov 2017 16:09:58 +0000 |
parents | |
children | 1fec387a4317 |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:4c8ae668cc8c |
---|---|
1 <?php | |
2 | |
3 namespace Drupal\user\Plugin\migrate; | |
4 | |
5 use Drupal\migrate\Exception\RequirementsException; | |
6 use Drupal\migrate_drupal\Plugin\migrate\FieldMigration; | |
7 | |
8 /** | |
9 * Plugin class for Drupal 7 user migrations dealing with fields and profiles. | |
10 */ | |
11 class User extends FieldMigration { | |
12 | |
13 /** | |
14 * {@inheritdoc} | |
15 */ | |
16 public function getProcess() { | |
17 if (!$this->init) { | |
18 $this->init = TRUE; | |
19 $definition['source'] = [ | |
20 'entity_type' => 'user', | |
21 'ignore_map' => TRUE, | |
22 ] + $this->source; | |
23 $definition['destination']['plugin'] = 'null'; | |
24 if (\Drupal::moduleHandler()->moduleExists('field')) { | |
25 $definition['source']['plugin'] = 'd7_field_instance'; | |
26 $field_migration = $this->migrationPluginManager->createStubMigration($definition); | |
27 foreach ($field_migration->getSourcePlugin() as $row) { | |
28 $field_name = $row->getSourceProperty('field_name'); | |
29 $field_type = $row->getSourceProperty('type'); | |
30 if (empty($field_type)) { | |
31 continue; | |
32 } | |
33 if ($this->fieldPluginManager->hasDefinition($field_type)) { | |
34 if (!isset($this->fieldPluginCache[$field_type])) { | |
35 $this->fieldPluginCache[$field_type] = $this->fieldPluginManager->createInstance($field_type, [], $this); | |
36 } | |
37 $info = $row->getSource(); | |
38 $this->fieldPluginCache[$field_type] | |
39 ->processFieldValues($this, $field_name, $info); | |
40 } | |
41 else { | |
42 if ($this->cckPluginManager->hasDefinition($field_type)) { | |
43 if (!isset($this->cckPluginCache[$field_type])) { | |
44 $this->cckPluginCache[$field_type] = $this->cckPluginManager->createInstance($field_type, [], $this); | |
45 } | |
46 $info = $row->getSource(); | |
47 $this->cckPluginCache[$field_type] | |
48 ->processCckFieldValues($this, $field_name, $info); | |
49 } | |
50 else { | |
51 $this->process[$field_name] = $field_name; | |
52 } | |
53 } | |
54 } | |
55 } | |
56 try { | |
57 $definition['source']['plugin'] = 'profile_field'; | |
58 $profile_migration = $this->migrationPluginManager->createStubMigration($definition); | |
59 // Ensure that Profile is enabled in the source DB. | |
60 $profile_migration->checkRequirements(); | |
61 foreach ($profile_migration->getSourcePlugin() as $row) { | |
62 $name = $row->getSourceProperty('name'); | |
63 $this->process[$name] = $name; | |
64 } | |
65 } | |
66 catch (RequirementsException $e) { | |
67 // The checkRequirements() call will fail when the profile module does | |
68 // not exist on the source site. | |
69 } | |
70 } | |
71 return parent::getProcess(); | |
72 } | |
73 | |
74 } |