3 namespace Drupal\comment\Plugin\migrate;
5 use Drupal\migrate_drupal\Plugin\migrate\FieldMigration;
8 * Migration plugin for Drupal 7 comments with fields.
10 class D7Comment extends FieldMigration {
15 public function getProcess() {
17 return parent::getProcess();
20 if (!\Drupal::moduleHandler()->moduleExists('field')) {
21 return parent::getProcess();
23 $definition['source'] = [
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);
37 $info = $row->getSource();
38 $this->fieldPluginCache[$field_type]->defineValueProcessPipeline($this, $field_name, $info);
41 $this->setProcessOfProperty($field_name, $field_name);
44 return parent::getProcess();