annotate 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
rev   line source
Chris@17 1 <?php
Chris@17 2
Chris@17 3 namespace Drupal\comment\Plugin\migrate;
Chris@17 4
Chris@17 5 use Drupal\migrate_drupal\Plugin\migrate\FieldMigration;
Chris@17 6
Chris@17 7 /**
Chris@17 8 * Migration plugin for Drupal 7 comments with fields.
Chris@17 9 */
Chris@17 10 class D7Comment extends FieldMigration {
Chris@17 11
Chris@17 12 /**
Chris@17 13 * {@inheritdoc}
Chris@17 14 */
Chris@17 15 public function getProcess() {
Chris@17 16 if ($this->init) {
Chris@17 17 return parent::getProcess();
Chris@17 18 }
Chris@17 19 $this->init = TRUE;
Chris@17 20 if (!\Drupal::moduleHandler()->moduleExists('field')) {
Chris@17 21 return parent::getProcess();
Chris@17 22 }
Chris@17 23 $definition['source'] = [
Chris@17 24 'ignore_map' => TRUE,
Chris@17 25 ] + $this->getSourceConfiguration();
Chris@17 26 $definition['source']['plugin'] = 'd7_field_instance';
Chris@17 27 $definition['destination']['plugin'] = 'null';
Chris@17 28 $definition['idMap']['plugin'] = 'null';
Chris@17 29 $field_migration = $this->migrationPluginManager->createStubMigration($definition);
Chris@17 30 foreach ($field_migration->getSourcePlugin() as $row) {
Chris@17 31 $field_name = $row->getSourceProperty('field_name');
Chris@17 32 $field_type = $row->getSourceProperty('type');
Chris@17 33 if ($this->fieldPluginManager->hasDefinition($field_type)) {
Chris@17 34 if (!isset($this->fieldPluginCache[$field_type])) {
Chris@17 35 $this->fieldPluginCache[$field_type] = $this->fieldPluginManager->createInstance($field_type, [], $this);
Chris@17 36 }
Chris@17 37 $info = $row->getSource();
Chris@17 38 $this->fieldPluginCache[$field_type]->defineValueProcessPipeline($this, $field_name, $info);
Chris@17 39 }
Chris@17 40 else {
Chris@17 41 $this->setProcessOfProperty($field_name, $field_name);
Chris@17 42 }
Chris@17 43 }
Chris@17 44 return parent::getProcess();
Chris@17 45 }
Chris@17 46
Chris@17 47 }