From 3e782507e18605dff176404c9b080fc955c39c7c Mon Sep 17 00:00:00 2001 From: Bachir Soussi Chiadmi Date: Thu, 30 Nov 2017 08:02:31 +0100 Subject: [PATCH] events migration done --- README.txt | 38 ----- ...rate_plus.migration.d6_edlp_evenements.yml | 73 +++++++++ .../migrate/source/D6EdlpEvenements.php | 138 ++++++++++++++++++ .../src/Plugin/migrate/source/D6EdlpPages.php | 2 +- 4 files changed, 212 insertions(+), 39 deletions(-) delete mode 100644 README.txt create mode 100644 sites/all/modules/figli/edlp_migrate/config/install/migrate_plus.migration.d6_edlp_evenements.yml create mode 100644 sites/all/modules/figli/edlp_migrate/src/Plugin/migrate/source/D6EdlpEvenements.php diff --git a/README.txt b/README.txt deleted file mode 100644 index 4c3935bc9..000000000 --- a/README.txt +++ /dev/null @@ -1,38 +0,0 @@ -# Encyclopédie de la parole (Drupal 8) - -## V3 from drupal 6 to drupal 8 - -the content of this site are migrated from a drupal 6 -you can find the migration custom module in /sites/all/modules/figli/edlp_migrate/ - -## About Drupal - -Drupal is an open source content management platform supporting a variety of -websites ranging from personal weblogs to large community-driven websites. For -more information, see the Drupal website at https://www.drupal.org, and join -the Drupal community at https://www.drupal.org/community. - -Legal information about Drupal: - * Know your rights when using Drupal: - See LICENSE.txt in the "core" directory. - * Learn about the Drupal trademark and logo policy: - https://www.drupal.com/trademark - - -MORE INFORMATION ----------------- - - * See the Drupal.org online documentation: - https://www.drupal.org/documentation - - * For a list of security announcements, see the "Security advisories" page at - https://www.drupal.org/security (available as an RSS feed). This page also - describes how to subscribe to these announcements via email. - - * For information about the Drupal security process, or to find out how to - report a potential security issue to the Drupal security team, see the - "Security team" page at https://www.drupal.org/security-team - - * For information about the wide range of available support options, visit - https://www.drupal.org and click on Community and Support in the top or - bottom navigation. diff --git a/sites/all/modules/figli/edlp_migrate/config/install/migrate_plus.migration.d6_edlp_evenements.yml b/sites/all/modules/figli/edlp_migrate/config/install/migrate_plus.migration.d6_edlp_evenements.yml new file mode 100644 index 000000000..a978d04c7 --- /dev/null +++ b/sites/all/modules/figli/edlp_migrate/config/install/migrate_plus.migration.d6_edlp_evenements.yml @@ -0,0 +1,73 @@ +id: d6_edlp_evenements +label: Edlp Drupal 6 evenement migration +migration_tags: + - Drupal 6 +deriver: Drupal\node\Plugin\migrate\D6NodeDeriver +migration_group: d6_edlp +source: + plugin: d6_edlp_evenements + node_type: event +process: + # In D6, nodes always have a tnid, but it's zero for untranslated nodes. + # We normalize it to equal the nid in that case. + # @see \Drupal\node\Plugin\migrate\source\d6\Node::prepareRow(). + # If you are using this file to build a custom migration consider removing + # the nid and vid fields to allow incremental migrations. + # nid: tnid + # vid: vid + type: + plugin: default_value + default_value: evenement + langcode: + plugin: default_value + source: language + default_value: "und" + title: + - + plugin: get + source: title + - + plugin: skip_on_empty + method: row + + # this is not working :( + uid: + - + plugin: migration_lookup + migration: d6_edlp_users + source: node_uid + - + plugin: default_value + default_value: 1 + + # status: status + created: created + changed: changed + promote: promote + sticky: sticky + revision_uid: revision_uid + revision_log: log + revision_timestamp: timestamp + + 'body/value': body + 'body/format': + plugin: default_value + default_value: wysiwyg + + # workflow + status: + plugin: static_map + source: workflow + map: + 1: 0 + 2: 0 + 3: 1 + 4: 1 + + field_date: field_date + +destination: + plugin: entity:node +migration_dependencies: + required: + - d6_edlp_users diff --git a/sites/all/modules/figli/edlp_migrate/src/Plugin/migrate/source/D6EdlpEvenements.php b/sites/all/modules/figli/edlp_migrate/src/Plugin/migrate/source/D6EdlpEvenements.php new file mode 100644 index 000000000..cbcc729ea --- /dev/null +++ b/sites/all/modules/figli/edlp_migrate/src/Plugin/migrate/source/D6EdlpEvenements.php @@ -0,0 +1,138 @@ +select('node_revisions', 'nr'); + $query->innerJoin('node', 'n', static::JOIN); + $this->handleTranslations($query); + + $query->fields('n', [ + 'nid', + 'type', + 'language', + 'status', + 'created', + 'changed', + 'comment', + 'promote', + 'moderate', + 'sticky', + 'tnid', + 'translate', + ]) + ->fields('nr', [ + 'title', + 'body', + 'teaser', + 'log', + 'timestamp', + 'format', + 'vid', + ]); + $query->addField('n', 'uid', 'node_uid'); + $query->addField('nr', 'uid', 'revision_uid'); + + // If the content_translation module is enabled, get the source langcode + // to fill the content_translation_source field. + if ($this->moduleHandler->moduleExists('content_translation')) { + $query->leftJoin('node', 'nt', 'n.tnid = nt.nid'); + $query->addField('nt', 'language', 'source_langcode'); + } + + if (isset($this->configuration['node_type'])) { + $query->condition('n.type', $this->configuration['node_type']); + } + + return $query; + } + + + /** + * {@inheritdoc} + */ + public function fields() { + + $fields = [ + 'nid' => $this->t('Node ID'), + 'type' => $this->t('Type'), + 'title' => $this->t('Title'), + 'body' => $this->t('Body'), + 'format' => $this->t('Format'), + 'teaser' => $this->t('Teaser'), + 'node_uid' => $this->t('Node authored by (uid)'), + 'revision_uid' => $this->t('Revision authored by (uid)'), + 'created' => $this->t('Created timestamp'), + 'changed' => $this->t('Modified timestamp'), + 'status' => $this->t('Published'), + 'promote' => $this->t('Promoted to front page'), + 'sticky' => $this->t('Sticky at top of lists'), + 'revision' => $this->t('Create new revision'), + 'language' => $this->t('Language (fr, en, ...)'), + 'tnid' => $this->t('The translation set id for this node'), + 'timestamp' => $this->t('The timestamp the latest revision of this node was created.'), + ]; + return $fields; + } + + /** + * {@inheritdoc} + */ + public function prepareRow(Row $row) { + drush_print(' '); + drush_print('- - - - - - - - - - - - - - - - - - - - - - - -'); + drush_print($row->getSourceProperty('title')); + + + // format = 0 can happen when the body field is hidden. Set the format to 1 + // to avoid migration map issues (since the body field isn't used anyway). + if ($row->getSourceProperty('format') === '0') { + $row->setSourceProperty('format', $this->filterDefaultFormat); + } + + if ($this->moduleExists('content') && $this->getModuleSchemaVersion('content') >= 6001) { + foreach ($this->getFieldValues($row) as $field => $values) { + $row->setSourceProperty($field, $values); + } + } + $row_nid = $row->getSourceProperty('nid'); + + + // Make sure we always have a translation set. + if ($row->getSourceProperty('tnid') == 0) { + $row->setSourceProperty('tnid', $row_nid); + } + + // get the workflow status + $query = $this->select('workflow_node', 'wn'); + $query->fields('wn', ['sid']); + $query->condition('wn.nid', $row_nid); + $results = $query->execute()->fetchField(); + // drush_print('workflow query results : ', 0, null, false); + // drush_print_r($results); + $row->setSourceProperty('workflow', $results); + + // TODO: fichiers attachés ?? + + $row = parent::prepareRow($row); + return $row; + } + + +} diff --git a/sites/all/modules/figli/edlp_migrate/src/Plugin/migrate/source/D6EdlpPages.php b/sites/all/modules/figli/edlp_migrate/src/Plugin/migrate/source/D6EdlpPages.php index f7e4c375a..14726dc36 100644 --- a/sites/all/modules/figli/edlp_migrate/src/Plugin/migrate/source/D6EdlpPages.php +++ b/sites/all/modules/figli/edlp_migrate/src/Plugin/migrate/source/D6EdlpPages.php @@ -175,7 +175,7 @@ class D6EdlpPages extends D6Node { drush_print_r($nid); // find the new nid of the enregistrement (corpus item) from migration map // get the d6_edlp_migration - // drush_print_r($this->migration->getIdMap()->lookupDestinationId(array($nid))); + // TODO: is this working for both corpus and sons elements ?? $new_nid = Database::getConnection('default', 'default') ->select('migrate_map_d6_edlp_sons', 'm') ->fields('m', ['destid1'])