comparison core/modules/comment/src/Plugin/migrate/D7Comment.php @ 17:129ea1e6d783

Update, including to Drupal core 8.6.10
author Chris Cannam
date Thu, 28 Feb 2019 13:21:36 +0000
parents
children af1871eacc83
comparison
equal deleted inserted replaced
16:c2387f117808 17:129ea1e6d783
1 <?php
2
3 namespace Drupal\comment\Plugin\migrate;
4
5 use Drupal\migrate_drupal\Plugin\migrate\FieldMigration;
6
7 /**
8 * Migration plugin for Drupal 7 comments with fields.
9 */
10 class D7Comment extends FieldMigration {
11
12 /**
13 * {@inheritdoc}
14 */
15 public function getProcess() {
16 if ($this->init) {
17 return parent::getProcess();
18 }
19 $this->init = TRUE;
20 if (!\Drupal::moduleHandler()->moduleExists('field')) {
21 return parent::getProcess();
22 }
23 $definition['source'] = [
24 'ignore_map' => TRUE,
25 ] + $this->getSourceConfiguration();
26 $definition['source']['plugin'] = 'd7_field_instance';
27 $definition['destination']['plugin'] = 'null';
28 $definition['idMap']['plugin'] = 'null';
29 $field_migration = $this->migrationPluginManager->createStubMigration($definition);
30 foreach ($field_migration->getSourcePlugin() as $row) {
31 $field_name = $row->getSourceProperty('field_name');
32 $field_type = $row->getSourceProperty('type');
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]->defineValueProcessPipeline($this, $field_name, $info);
39 }
40 else {
41 $this->setProcessOfProperty($field_name, $field_name);
42 }
43 }
44 return parent::getProcess();
45 }
46
47 }