diff --git a/sites/all/modules/figli/edlp_migrate/config/install/migrate_plus.migration.d6_edlp_allfiles.yml b/sites/all/modules/figli/edlp_migrate/config/install/migrate_plus.migration.d6_edlp_allfiles.yml new file mode 100644 index 000000000..7f4bd2a24 --- /dev/null +++ b/sites/all/modules/figli/edlp_migrate/config/install/migrate_plus.migration.d6_edlp_allfiles.yml @@ -0,0 +1,52 @@ +# Every migration that references a file by Drupal 6 fid should specify this +# migration as an optional dependency. +id: d6_edlp_allfiles +label: Edlp Drupal 6 mp3 migration +migration_tags: + - Drupal 6 +migration_group: d6_edlp +source: + plugin: d6_file + constants: + # The tool configuring this migration must set source_base_path. It + # represents the fully qualified path relative to which URIs in the files + # table are specified, and must end with a /. See source_full_path + # configuration in this migration's process pipeline as an example. + source_base_path: '../drupal6/' + +process: + # If you are using both this migration and d6_user_picture_file in a custom + # migration and executing migrations incrementally, it is strongly + # recommended that you remove the fid mapping to avoid potential ID + # conflicts. For that reason, this mapping is commented out by default. + fid: fid + filename: filename + source_full_path: + - + plugin: concat + delimiter: / + source: + - constants/source_base_path + - filepath + - + plugin: urlencode + destination_full_path: + plugin: file_uri + source: + - filepath + - file_directory_path + - temp_directory_path + - is_public + uri: + plugin: file_copy + source: + - '@source_full_path' + - '@destination_full_path' + filemime: filemime + # No need to migrate filesize, it is computed when file entities are saved. + # filesize: filesize + status: status + changed: timestamp + uid: uid +destination: + plugin: entity:file diff --git a/sites/all/modules/figli/edlp_migrate/config/install/migrate_plus.migration.d6_edlp_corpus.yml b/sites/all/modules/figli/edlp_migrate/config/install/migrate_plus.migration.d6_edlp_corpus.yml new file mode 100644 index 000000000..cdd4504f4 --- /dev/null +++ b/sites/all/modules/figli/edlp_migrate/config/install/migrate_plus.migration.d6_edlp_corpus.yml @@ -0,0 +1,155 @@ +id: d6_edlp_corpus +label: Edlp Drupal 6 corpus +migration_tags: + - Drupal 6 +deriver: Drupal\node\Plugin\migrate\D6NodeDeriver +migration_group: d6_edlp +source: + plugin: d6_edlp_corpus + node_type: corpus +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: enregistrement + 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 + # 'body/format': + # plugin: migration_lookup + # migration: d6_filter_format + # source: format + + # ARTICLE (body) + # node ref -> text + # 'body/value': here we have to get the body value of article + # 'body/summary': teaser + + revision_uid: revision_uid + revision_log: log + revision_timestamp: timestamp + # + # custom fields + # workflow + + # text -> entity ref terms + # field_artiste: field_locuteur_s + # field_locuteurs_s: + # plugin: entity_generate + # entity_type: taxonomy_term + # bundle_key: vid + # bundle: locuteurs + # source: field_artiste + # value_key: field_artiste_value + + + # text -> entity ref terms + # field_compositeur: field_collectionneur_s + # field_collectionneur_s: + # plugin: entity_generate + # entity_type: taxonomy_term + # bundle_key: vid + # bundle: collectionneurs + # source: field_compositeur + # value_key: field_compositeur_value + + # taxo term -> entity ref terms + # field_entree_s: + # plugin: iterator + # source: + # plugin: migration_lookup + # migration: d6_edlp_entrees + # source: name + + # field_genre: field_genre_s + field_genre_s: + - + plugin: iterator + source: field_genre + process: + tid: value + - + plugin: flatten + # - + # plugin: migration_lookup + # migration: d6_edlp_genres + + # plugin: migration + # migration: d6_edlp_genres + # source: field_genre + + # plugin: iterator + # source: field_genre + # process: + # target_id: + # plugin: migration_lookup + # migration: d6_edlp_genres + # source: value + + # taxo term -> entity ref terms + # field_langue: field_langue_s + + # file + # field_mp3: field_fichier_son + field_fichier_son: + plugin: migration_lookup + migration: d6_edlp_allfiles + source: fid + + # plugin: iterator + # source: field_mp3 + # process: + # target_id: + # plugin: migration_lookup + # migration: d6_edlp_allfiles + # source: fid + + field_notes: body + + + +# unmapped d6 fields. +# tnid +# translate +# moderate +# comment + +destination: + plugin: entity:node +migration_dependencies: + required: + - d6_edlp_users + - d6_edlp_entrees + - d6_edlp_genres + - d6_edlp_langues + - d6_edlp_allfiles diff --git a/sites/all/modules/figli/edlp_migrate/config/install/migrate_plus.migration.d6_edlp_entrees.yml b/sites/all/modules/figli/edlp_migrate/config/install/migrate_plus.migration.d6_edlp_entrees.yml new file mode 100644 index 000000000..a9e452395 --- /dev/null +++ b/sites/all/modules/figli/edlp_migrate/config/install/migrate_plus.migration.d6_edlp_entrees.yml @@ -0,0 +1,27 @@ +id: d6_edlp_entrees +label: Edlp Drupal 6 entrees +migration_tags: + - Drupal 6 +migration_group: d6_edlp +source: + plugin: d6_edlp_taxonomy_term_entree + bundle: 2 +process: + name: name + description: + - + plugin: get + source: description + - + plugin: skip_on_empty + method: row + + vid: + plugin: default_value + default_value: entrees + weight: weight + +# todo : get the node type entrée from source and add it to description field (we need a plugin for that) + +destination: + plugin: entity:taxonomy_term diff --git a/sites/all/modules/figli/edlp_migrate/config/install/migrate_plus.migration.edlpd6genres.yml b/sites/all/modules/figli/edlp_migrate/config/install/migrate_plus.migration.d6_edlp_genres.yml similarity index 85% rename from sites/all/modules/figli/edlp_migrate/config/install/migrate_plus.migration.edlpd6genres.yml rename to sites/all/modules/figli/edlp_migrate/config/install/migrate_plus.migration.d6_edlp_genres.yml index 5c6087845..318868e3c 100644 --- a/sites/all/modules/figli/edlp_migrate/config/install/migrate_plus.migration.edlpd6genres.yml +++ b/sites/all/modules/figli/edlp_migrate/config/install/migrate_plus.migration.d6_edlp_genres.yml @@ -1,8 +1,8 @@ -id: edlp_d6_genres +id: d6_edlp_genres label: Edlp Drupal 6 genres migration_tags: - Drupal 6 -migration_group: edlp +migration_group: d6_edlp source: plugin: d6_taxonomy_term bundle: 3 diff --git a/sites/all/modules/figli/edlp_migrate/config/install/migrate_plus.migration.edlpd6langues.yml b/sites/all/modules/figli/edlp_migrate/config/install/migrate_plus.migration.d6_edlp_langues.yml similarity index 85% rename from sites/all/modules/figli/edlp_migrate/config/install/migrate_plus.migration.edlpd6langues.yml rename to sites/all/modules/figli/edlp_migrate/config/install/migrate_plus.migration.d6_edlp_langues.yml index 887b35818..708443a1b 100644 --- a/sites/all/modules/figli/edlp_migrate/config/install/migrate_plus.migration.edlpd6langues.yml +++ b/sites/all/modules/figli/edlp_migrate/config/install/migrate_plus.migration.d6_edlp_langues.yml @@ -1,8 +1,8 @@ -id: edlp_d6_langues +id: d6_edlp_langues label: Edlp Drupal 6 langues migration_tags: - Drupal 6 -migration_group: edlp +migration_group: d6_edlp source: plugin: d6_taxonomy_term bundle: 4 diff --git a/sites/all/modules/figli/edlp_migrate/config/install/migrate_plus.migration.edlpd6users.yml b/sites/all/modules/figli/edlp_migrate/config/install/migrate_plus.migration.d6_edlp_users.yml similarity index 93% rename from sites/all/modules/figli/edlp_migrate/config/install/migrate_plus.migration.edlpd6users.yml rename to sites/all/modules/figli/edlp_migrate/config/install/migrate_plus.migration.d6_edlp_users.yml index 9f3ac4fca..b4432836e 100644 --- a/sites/all/modules/figli/edlp_migrate/config/install/migrate_plus.migration.edlpd6users.yml +++ b/sites/all/modules/figli/edlp_migrate/config/install/migrate_plus.migration.d6_edlp_users.yml @@ -1,10 +1,10 @@ -id: edlp_d6_users +id: d6_edlp_users label: Edlp Drupal 6 User accounts migration_tags: - Drupal 6 -migration_group: edlp +migration_group: d6_edlp source: - plugin: edlp_d6_users + plugin: d6_edlp_users process: # If you are using this file to build a custom migration consider removing # the uid field to allow incremental migrations. diff --git a/sites/all/modules/figli/edlp_migrate/config/install/migrate_plus.migration.edlpd6corpus.yml b/sites/all/modules/figli/edlp_migrate/config/install/migrate_plus.migration.edlpd6corpus.yml deleted file mode 100644 index c2908354b..000000000 --- a/sites/all/modules/figli/edlp_migrate/config/install/migrate_plus.migration.edlpd6corpus.yml +++ /dev/null @@ -1,90 +0,0 @@ -id: edlp_d6_corpus -label: Edlp Drupal 6 corpus -migration_tags: - - Drupal 6 -deriver: Drupal\node\Plugin\migrate\D6NodeDeriver -migration_group: edlp -source: - plugin: edlp_d6_corpus - node_type: corpus -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: enregistrement - langcode: - plugin: default_value - source: language - default_value: "und" - title: title - uid: - plugin: migration - migration: edlp_d6_users - source: uid - status: status - created: created - changed: changed - promote: promote - sticky: sticky - # 'body/format': - # plugin: migration_lookup - # migration: d6_filter_format - # source: format - 'body/value': notes - # 'body/summary': teaser - revision_uid: revision_uid - revision_log: log - revision_timestamp: timestamp - # - # custom fields - # workflow - # text -> entity ref terms - # field_artiste: field_locuteur_s - # text -> entity ref terms - # field_compositeur: field_collectionneur_s - - # taxo term -> entity ref terms - # field_entree_s: - # plugin: entity_generate - # source: Type - # entity_type: taxonomy_term - # bundle_key: vid - # bundle: entrees - # value_key: name - - # field_genre: field_genre_s - # field_genre_s: - # plugin: entity_generate - # source: field_genre - # entity_type: taxonomy_term - # bundle_key: vid - # bundle: genres - # value_key: name - - # taxo term -> entity ref terms - # field_langue: field_langue_s - # file - # field_mp3: field_fichier_son - # node ref -> text - # field_article: body - - - -# unmapped d6 fields. -# tnid -# translate -# moderate -# comment - -destination: - plugin: entity:node -migration_dependencies: - required: - - edlp_d6_users - - edlp_d6_entrees diff --git a/sites/all/modules/figli/edlp_migrate/config/install/migrate_plus.migration.edlpd6entrees.yml b/sites/all/modules/figli/edlp_migrate/config/install/migrate_plus.migration.edlpd6entrees.yml deleted file mode 100644 index d31b812ba..000000000 --- a/sites/all/modules/figli/edlp_migrate/config/install/migrate_plus.migration.edlpd6entrees.yml +++ /dev/null @@ -1,17 +0,0 @@ -id: edlp_d6_entrees -label: Edlp Drupal 6 entrees -migration_tags: - - Drupal 6 -migration_group: edlp -source: - plugin: d6_taxonomy_term - bundle: 2 -process: - name: name - description: description - vid: - plugin: default_value - default_value: entrees - -destination: - plugin: entity:taxonomy_term diff --git a/sites/all/modules/figli/edlp_migrate/config/install/migrate_plus.migration_group.d6_edlp.yml b/sites/all/modules/figli/edlp_migrate/config/install/migrate_plus.migration_group.d6_edlp.yml new file mode 100644 index 000000000..d61f3a835 --- /dev/null +++ b/sites/all/modules/figli/edlp_migrate/config/install/migrate_plus.migration_group.d6_edlp.yml @@ -0,0 +1,7 @@ +id: d6_edlp +label: D6 Edlp +description: Drupal 6 edlp content migration to Drupal 8. +source_type: Drupal 6. +shared_configuration: + source: + key: legacy diff --git a/sites/all/modules/figli/edlp_migrate/edlp_migrate.info.yml b/sites/all/modules/figli/edlp_migrate/edlp_migrate.info.yml index 82590e56d..a60427064 100644 --- a/sites/all/modules/figli/edlp_migrate/edlp_migrate.info.yml +++ b/sites/all/modules/figli/edlp_migrate/edlp_migrate.info.yml @@ -6,3 +6,4 @@ package: Edlp dependencies: - migrate_drupal - migrate_plus + - migrate_tools diff --git a/sites/all/modules/figli/edlp_migrate/migrate_plus.migration_group.edlp.yml b/sites/all/modules/figli/edlp_migrate/migrate_plus.migration_group.edlp.yml deleted file mode 100644 index 6fd634015..000000000 --- a/sites/all/modules/figli/edlp_migrate/migrate_plus.migration_group.edlp.yml +++ /dev/null @@ -1,7 +0,0 @@ -id: edlp -label: Edlp -description: Drupal 6 edlp content migrated to Drupal 8. -source_type: Drupal 6. -shared_configuration: - source: - key: legacy diff --git a/sites/all/modules/figli/edlp_migrate/readme.md b/sites/all/modules/figli/edlp_migrate/readme.md index 00c3f4925..f269aaf22 100644 --- a/sites/all/modules/figli/edlp_migrate/readme.md +++ b/sites/all/modules/figli/edlp_migrate/readme.md @@ -9,3 +9,15 @@ https://drupal.stackexchange.com/questions/164612/how-do-i-remove-a-configuratio https://www.metaltoad.com/blog/drupal-8-migrations-part-3-migrating-taxonomies-drupal-7 https://www.sitepoint.com/your-first-drupal-8-migration/ + +https://evolvingweb.ca/blog/drupal-8-migration-migrating-taxonomy-term-references-part-2 + +[text to taxonomy term](http://boylesoftware.com/blog/drupal-8-migration-taxonomy-term-lookups/) + +[Upgrading Drupal 6 and i18n Content Translation to Drupal 8](https://www.dunix-data.de/blog/upgrading_drupal_6_and_i18n_content_translation_to_drupal_8) + +[Migrating Drupal 7 File Entities to Drupal 8 Media Entities](https://www.previousnext.com.au/blog/migrating-drupal-7-file-entities-drupal-8-media-entities) + +[D6 Taxonomy Term Reference Field is not migrated to D8 Field](https://www.drupal.org/node/2884240) + +[Migrer un site Drupal 6 ou Drupal 7 vers Drupal 8](https://www.drupalfacile.org/sites/drupalfacile/files/blog/2016/06/dcnantes2016-migrerd6d7versd8.pdf) diff --git a/sites/all/modules/figli/edlp_migrate/src/Plugin/migrate/source/D6EdlpCorpus.php b/sites/all/modules/figli/edlp_migrate/src/Plugin/migrate/source/D6EdlpCorpus.php new file mode 100644 index 000000000..d88824d53 --- /dev/null +++ b/sites/all/modules/figli/edlp_migrate/src/Plugin/migrate/source/D6EdlpCorpus.php @@ -0,0 +1,124 @@ +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) { + // 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); + // \Drupal::logger('edlp_migrate')->debug(print_r($values)); + // print_r($field); + // print_r("\n"); + // print_r($values); + } + } + + // Make sure we always have a translation set. + if ($row->getSourceProperty('tnid') == 0) { + $row->setSourceProperty('tnid', $row->getSourceProperty('nid')); + } + + $row = parent::prepareRow($row); + return $row; + } + + +} diff --git a/sites/all/modules/figli/edlp_migrate/src/Plugin/migrate/source/D6EdlpTaxonomyTermEntree.php b/sites/all/modules/figli/edlp_migrate/src/Plugin/migrate/source/D6EdlpTaxonomyTermEntree.php new file mode 100644 index 000000000..d80be3f86 --- /dev/null +++ b/sites/all/modules/figli/edlp_migrate/src/Plugin/migrate/source/D6EdlpTaxonomyTermEntree.php @@ -0,0 +1,94 @@ +select('term_data', 'td') + ->fields('td') + ->distinct() + ->orderBy('td.tid'); + + if (isset($this->configuration['bundle'])) { + $query->condition('td.vid', (array) $this->configuration['bundle'], 'IN'); + } + + return $query; + } + + /** + * {@inheritdoc} + */ + public function fields() { + $fields = [ + 'tid' => $this->t('The term ID.'), + 'vid' => $this->t('Existing term VID'), + 'name' => $this->t('The name of the term.'), + 'description' => $this->t('The term description.'), + 'weight' => $this->t('Weight'), + 'parent' => $this->t("The Drupal term IDs of the term's parents."), + 'node_nid' => $this->t("The node's nid of entree's description."), + ]; + if (isset($this->configuration['translations'])) { + $fields['language'] = $this->t('The term language.'); + $fields['trid'] = $this->t('Translation ID.'); + } + // print_r($fields); + // print_r("\n"); + + return $fields; + } + + /** + * {@inheritdoc} + */ + public function prepareRow(Row $row) { + // drush_print_r($row); + // Find parents for this row. + $parents = $this->select('term_hierarchy', 'th') + ->fields('th', ['parent', 'tid']) + ->condition('tid', $row->getSourceProperty('tid')) + ->execute() + ->fetchCol(); + $row->setSourceProperty('parent', $parents); + + // find node attached to this term for description + $query = $this->select('content_type_entree', 'cte'); + // $query->fields('cte', ['nid', 'vid', 'field_entree_value']); + $query->condition('cte.field_entree_value', $row->getSourceProperty('tid')); + $query->join('node_revisions', 'nr', 'cte.nid = nr.nid'); + $query->addField('nr', 'body'); + $description = $query->execute() + ->fetchField(); + + // drush_print_r($node); + $row->setSourceProperty('description', $description); + + return parent::prepareRow($row); + } + + /** + * {@inheritdoc} + */ + public function getIds() { + $ids['tid']['type'] = 'integer'; + return $ids; + } + +} diff --git a/sites/all/modules/figli/edlp_migrate/src/Plugin/migrate/source/EdlpD6Users.php b/sites/all/modules/figli/edlp_migrate/src/Plugin/migrate/source/D6EdlpUsers.php similarity index 98% rename from sites/all/modules/figli/edlp_migrate/src/Plugin/migrate/source/EdlpD6Users.php rename to sites/all/modules/figli/edlp_migrate/src/Plugin/migrate/source/D6EdlpUsers.php index 5189dc7ff..9392c94fe 100644 --- a/sites/all/modules/figli/edlp_migrate/src/Plugin/migrate/source/EdlpD6Users.php +++ b/sites/all/modules/figli/edlp_migrate/src/Plugin/migrate/source/D6EdlpUsers.php @@ -9,10 +9,10 @@ use Drupal\user\Plugin\migrate\source\d6\User as D6User; * Source plugin for edlp user accounts. * * @MigrateSource( - * id = "edlp_d6_users" + * id = "d6_edlp_users" * ) */ -class EdlpD6Users extends D6User { +class D6EdlpUsers extends D6User { /** * {@inheritdoc} diff --git a/sites/all/modules/figli/edlp_migrate/src/Plugin/migrate/source/EdlpD6Corpus.php b/sites/all/modules/figli/edlp_migrate/src/Plugin/migrate/source/EdlpD6Corpus.php deleted file mode 100644 index 486f67b73..000000000 --- a/sites/all/modules/figli/edlp_migrate/src/Plugin/migrate/source/EdlpD6Corpus.php +++ /dev/null @@ -1,18 +0,0 @@ -