From 796fd2f576e5c3d1a94209530f561b06b3d1d9c6 Mon Sep 17 00:00:00 2001 From: bach Date: Mon, 19 Apr 2021 12:10:17 +0200 Subject: [PATCH] popsu_migrate: D7NodeTheme type de themes ok --- ...grate_plus.migration.d7_allpublicfiles.yml | 2 +- ...grate_plus.migration.d7_node_programme.yml | 2 +- .../migrate_plus.migration.d7_node_theme.yml | 10 +- ....migration.d7_taxonomy_term_type_theme.yml | 43 ++++++ .../sync/migrate_plus.migration.d7_users.yml | 2 +- .../migrate_plus.migration_group.popsu.yml | 2 +- .../migrate_plus.migration_group.pospsu.yml | 10 ++ config/sync/views.view.content.yml | 139 ++++++++++++++++++ .../migrate_plus.migration.d7_node_theme.yml | 7 + ....migration.d7_taxonomy_term_type_theme.yml | 42 ++++++ .../src/Plugin/migrate/source/D7NodeTheme.php | 2 +- .../migrate/source/D7TaxotermTypetheme.php | 95 ++++++++++++ 12 files changed, 349 insertions(+), 7 deletions(-) create mode 100644 config/sync/migrate_plus.migration.d7_taxonomy_term_type_theme.yml create mode 100644 config/sync/migrate_plus.migration_group.pospsu.yml create mode 100644 web/modules/custom/popsu_migrate/config/install/migrate_plus.migration.d7_taxonomy_term_type_theme.yml create mode 100644 web/modules/custom/popsu_migrate/src/Plugin/migrate/source/D7TaxotermTypetheme.php diff --git a/config/sync/migrate_plus.migration.d7_allpublicfiles.yml b/config/sync/migrate_plus.migration.d7_allpublicfiles.yml index 22070a96..4d7598db 100644 --- a/config/sync/migrate_plus.migration.d7_allpublicfiles.yml +++ b/config/sync/migrate_plus.migration.d7_allpublicfiles.yml @@ -1,4 +1,4 @@ -uuid: 109c9789-49c4-496b-9752-dbef07f4844f +uuid: 48293cc8-6d3e-4319-94d5-5a084cc43922 langcode: fr status: true dependencies: { } diff --git a/config/sync/migrate_plus.migration.d7_node_programme.yml b/config/sync/migrate_plus.migration.d7_node_programme.yml index f62efd84..e7c520a2 100644 --- a/config/sync/migrate_plus.migration.d7_node_programme.yml +++ b/config/sync/migrate_plus.migration.d7_node_programme.yml @@ -1,4 +1,4 @@ -uuid: 4f12194e-d946-4dac-951d-473619e7e1fa +uuid: 6792e7bc-de9a-426f-a025-2714ebdae9c6 langcode: fr status: true dependencies: { } diff --git a/config/sync/migrate_plus.migration.d7_node_theme.yml b/config/sync/migrate_plus.migration.d7_node_theme.yml index 4ff7624a..c1616037 100644 --- a/config/sync/migrate_plus.migration.d7_node_theme.yml +++ b/config/sync/migrate_plus.migration.d7_node_theme.yml @@ -1,9 +1,9 @@ -uuid: 33fb807a-7941-481f-85c6-745336b34fde +uuid: da306ac3-31b7-48db-b5cd-bca61bed030d langcode: fr status: true dependencies: { } _core: - default_config_hash: rJxQh2W7x4hn1fMvgAiyjsdjG3SPO8Re_q5Zv15hgcQ + default_config_hash: uXnA5dnBQRk7D5gA4_B-KY4azpiVJY8-B9E7aIwHb7A id: d7_node_theme class: null field_plugin_method: null @@ -46,9 +46,15 @@ process: no_stub: true alt: alt title: title + field_type_de_theme: + plugin: migration_lookup + migration: d7_taxonomy_term_type_theme + source: field_popsu_themtrans_type + no_stub: true destination: plugin: 'entity:node' migration_dependencies: required: - d7_allpublicfiles - d7_users + - d7_taxonomy_term_type_theme diff --git a/config/sync/migrate_plus.migration.d7_taxonomy_term_type_theme.yml b/config/sync/migrate_plus.migration.d7_taxonomy_term_type_theme.yml new file mode 100644 index 00000000..d5c3e37e --- /dev/null +++ b/config/sync/migrate_plus.migration.d7_taxonomy_term_type_theme.yml @@ -0,0 +1,43 @@ +uuid: 5271f877-ecf0-43f0-8b85-935338468cb9 +langcode: fr +status: true +dependencies: { } +_core: + default_config_hash: 8WKuGBlZ5qPBjASOe5KMfJVNAdp2h7h-cu46cvt-Q-s +id: d7_taxonomy_term_type_theme +class: null +field_plugin_method: null +cck_plugin_method: null +migration_tags: + - 'Drupal 7' + - Content + - Popsu +migration_group: popsu +label: 'Taxonomy terms Type de theme' +source: + plugin: d7_taxoterm_typetheme + bundle: popsu_themtrans +process: + vid: + plugin: default_value + default_value: types_de_theme + name: name + description/value: description + description/format: format + weight: weight + parent_id: + - + plugin: skip_on_empty + method: process + source: parent + - + plugin: migration_lookup + migration: d7_taxonomy_term_type_theme + parent: + plugin: default_value + default_value: 0 + source: '@parent_id' + changed: timestamp +destination: + plugin: 'entity:taxonomy_term' +migration_dependencies: null diff --git a/config/sync/migrate_plus.migration.d7_users.yml b/config/sync/migrate_plus.migration.d7_users.yml index 7cfae96a..cb893c41 100644 --- a/config/sync/migrate_plus.migration.d7_users.yml +++ b/config/sync/migrate_plus.migration.d7_users.yml @@ -1,4 +1,4 @@ -uuid: f4fce287-cf41-4cbd-bc42-d38df4c92f24 +uuid: 7ec8eb78-7884-4c82-9996-ad70c1413c45 langcode: fr status: true dependencies: { } diff --git a/config/sync/migrate_plus.migration_group.popsu.yml b/config/sync/migrate_plus.migration_group.popsu.yml index c282f6db..7ca2c662 100644 --- a/config/sync/migrate_plus.migration_group.popsu.yml +++ b/config/sync/migrate_plus.migration_group.popsu.yml @@ -1,4 +1,4 @@ -uuid: 734983b5-c217-433d-ac9c-6c923c681360 +uuid: 4723b02a-b61d-4833-bb03-b7a2dfa6b42e langcode: fr status: true dependencies: diff --git a/config/sync/migrate_plus.migration_group.pospsu.yml b/config/sync/migrate_plus.migration_group.pospsu.yml new file mode 100644 index 00000000..f8dadf78 --- /dev/null +++ b/config/sync/migrate_plus.migration_group.pospsu.yml @@ -0,0 +1,10 @@ +uuid: b23aa4de-a0e2-4988-8e48-136de4554664 +langcode: fr +status: true +dependencies: { } +id: pospsu +label: pospsu +description: '' +source_type: null +module: null +shared_configuration: null diff --git a/config/sync/views.view.content.yml b/config/sync/views.view.content.yml index c9ca51b1..9d9d86d4 100644 --- a/config/sync/views.view.content.yml +++ b/config/sync/views.view.content.yml @@ -5,12 +5,15 @@ dependencies: config: - field.storage.node.field_image - field.storage.node.field_programme + - field.storage.node.field_type_de_theme - image.style.thumbnail - node.type.programme - node.type.theme + - taxonomy.vocabulary.types_de_theme module: - image - node + - taxonomy - user _core: default_config_hash: P7F4DFe8BL31DRVqsvS-ix9KZZqvvaPjZ7zEvGo9yNM @@ -64,7 +67,9 @@ display: description: '' columns: node_bulk_form: node_bulk_form + field_image: field_image title: title + field_type_de_theme: title operations: title field_programme: field_programme status: status @@ -75,6 +80,13 @@ display: separator: '' empty_column: false responsive: '' + field_image: + sortable: false + default_sort_order: asc + align: '' + separator: '' + empty_column: false + responsive: '' title: sortable: true default_sort_order: asc @@ -82,6 +94,13 @@ display: separator: '
' empty_column: false responsive: '' + field_type_de_theme: + sortable: false + default_sort_order: asc + align: '' + separator: '' + empty_column: false + responsive: '' operations: align: '' separator: '' @@ -908,6 +927,62 @@ display: default_group_multiple: { } group_items: { } plugin_id: numeric + field_type_de_theme_target_id: + id: field_type_de_theme_target_id + table: node__field_type_de_theme + field: field_type_de_theme_target_id + relationship: none + group_type: group + admin_label: '' + operator: or + value: { } + group: 1 + exposed: true + expose: + operator_id: field_type_de_theme_target_id_op + label: 'Type de theme (field_type_de_theme)' + description: '' + use_operator: false + operator: field_type_de_theme_target_id_op + operator_limit_selection: false + operator_list: { } + identifier: field_type_de_theme_target_id + required: false + remember: false + multiple: false + remember_roles: + authenticated: authenticated + anonymous: '0' + admin: '0' + root: '0' + user: '0' + editeur: '0' + reduce: false + is_grouped: false + group_info: + label: '' + description: '' + identifier: '' + optional: true + widget: select + multiple: false + remember: false + default_group: All + default_group_multiple: { } + group_items: { } + reduce_duplicates: false + type: textfield + limit: true + vid: types_de_theme + hierarchy: false + error_message: true + parent: 0 + level_labels: '' + force_deepest: false + save_lineage: false + hierarchy_depth: 0 + required_depth: 0 + plugin_id: taxonomy_index_tid defaults: filters: false filter_groups: false @@ -1017,6 +1092,69 @@ display: settings: link_to_entity: true plugin_id: field + field_type_de_theme: + id: field_type_de_theme + table: node__field_type_de_theme + field: field_type_de_theme + relationship: none + group_type: group + admin_label: '' + label: 'Type de theme' + exclude: false + alter: + alter_text: false + text: '' + make_link: false + path: '' + absolute: false + external: false + replace_spaces: false + path_case: none + trim_whitespace: false + alt: '' + rel: '' + link_class: '' + prefix: '' + suffix: '' + target: '' + nl2br: false + max_length: 0 + word_boundary: true + ellipsis: true + more_link: false + more_link_text: '' + more_link_path: '' + strip_tags: false + trim: false + preserve_tags: '' + html: false + element_type: '' + element_class: '' + element_label_type: '' + element_label_class: '' + element_label_colon: true + element_wrapper_type: '' + element_wrapper_class: '' + element_default_classes: true + empty: '' + hide_empty: false + empty_zero: false + hide_alter_empty: true + click_sort_column: target_id + type: entity_reference_label + settings: + link: true + group_column: target_id + group_columns: { } + group_rows: true + delta_limit: 0 + delta_offset: 0 + delta_reversed: false + delta_first_last: false + multi_type: separator + separator: ', ' + field_api_classes: false + plugin_id: field operations: id: operations table: node @@ -1191,3 +1329,4 @@ display: tags: - 'config:field.storage.node.field_image' - 'config:field.storage.node.field_programme' + - 'config:field.storage.node.field_type_de_theme' diff --git a/web/modules/custom/popsu_migrate/config/install/migrate_plus.migration.d7_node_theme.yml b/web/modules/custom/popsu_migrate/config/install/migrate_plus.migration.d7_node_theme.yml index add8fab6..f574e00a 100644 --- a/web/modules/custom/popsu_migrate/config/install/migrate_plus.migration.d7_node_theme.yml +++ b/web/modules/custom/popsu_migrate/config/install/migrate_plus.migration.d7_node_theme.yml @@ -50,7 +50,14 @@ process: alt: alt title: title + field_type_de_theme: + plugin: migration_lookup + migration: d7_taxonomy_term_type_theme + source: field_popsu_themtrans_type + no_stub: true + migration_dependencies: required: - d7_allpublicfiles - d7_users + - d7_taxonomy_term_type_theme diff --git a/web/modules/custom/popsu_migrate/config/install/migrate_plus.migration.d7_taxonomy_term_type_theme.yml b/web/modules/custom/popsu_migrate/config/install/migrate_plus.migration.d7_taxonomy_term_type_theme.yml new file mode 100644 index 00000000..19f03305 --- /dev/null +++ b/web/modules/custom/popsu_migrate/config/install/migrate_plus.migration.d7_taxonomy_term_type_theme.yml @@ -0,0 +1,42 @@ +id: d7_taxonomy_term_type_theme +label: Taxonomy terms Type de theme +migration_group: popsu +audit: true +migration_tags: + - Drupal 7 + - Content + - Popsu +deriver: Drupal\taxonomy\Plugin\migrate\D7TaxonomyTermDeriver + +source: + plugin: d7_taxoterm_typetheme + bundle: popsu_themtrans + +destination: + plugin: entity:taxonomy_term + +process: + # If you are using this file to build a custom migration consider removing + # the tid field to allow incremental migrations. + # tid: tid + vid: + plugin: default_value + default_value: types_de_theme + name: name + 'description/value': description + 'description/format': format + weight: weight + # Only attempt to stub real (non-zero) parents. + parent_id: + - + plugin: skip_on_empty + method: process + source: parent + - + plugin: migration_lookup + migration: d7_taxonomy_term_type_theme + parent: + plugin: default_value + default_value: 0 + source: '@parent_id' + changed: timestamp diff --git a/web/modules/custom/popsu_migrate/src/Plugin/migrate/source/D7NodeTheme.php b/web/modules/custom/popsu_migrate/src/Plugin/migrate/source/D7NodeTheme.php index 7d950dea..f52b9e73 100644 --- a/web/modules/custom/popsu_migrate/src/Plugin/migrate/source/D7NodeTheme.php +++ b/web/modules/custom/popsu_migrate/src/Plugin/migrate/source/D7NodeTheme.php @@ -161,7 +161,7 @@ class D7NodeTheme extends FieldableEntity { } if ($field_images) { - Drush::output()->writeln(dump($field_images)); + // Drush::output()->writeln(dump($field_images)); $row->setSourceProperty('images', $field_images); } diff --git a/web/modules/custom/popsu_migrate/src/Plugin/migrate/source/D7TaxotermTypetheme.php b/web/modules/custom/popsu_migrate/src/Plugin/migrate/source/D7TaxotermTypetheme.php new file mode 100644 index 00000000..793617c8 --- /dev/null +++ b/web/modules/custom/popsu_migrate/src/Plugin/migrate/source/D7TaxotermTypetheme.php @@ -0,0 +1,95 @@ +select('taxonomy_term_data', 'td') + ->fields('td') + ->orderBy('tid'); + + $query->leftJoin('taxonomy_vocabulary', 'tv', 'td.vid = tv.vid'); + $query->addField('tv', 'machine_name'); + + if (isset($this->configuration['bundle'])) { + $query->condition('tv.machine_name', (array) $this->configuration['bundle'], 'IN'); + } + + return $query; + } + + /** + * {@inheritdoc} + */ + public function fields() { + $fields = [ + 'tid' => $this->t('The term ID.'), + 'vid' => $this->t('Existing term VID'), + 'machine_name' => $this->t('Vocabulary machine name'), + '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."), + 'format' => $this->t("Format of the term description."), + 'synonyms' => $this->t("Term's Synonyms (field : synonyms_synonym)"), + 'displayed_on_advanced_search' => $this->t("field_used_on_advanced_search"), + 'revision_id' => $this->t('Revision ID'), + 'language' => $this->t('Term translation language'), + 'source' => $this->t('Term translation source language'), + ]; + return $fields; + } + + + /** + * {@inheritdoc} + */ + public function prepareRow(Row $row) { + $language = $row->getSourceProperty('language'); + // drush_print('-- '.$language."\t".$row->getSourceProperty('tid')."\t".$row->getSourceProperty('name')); + + $tid = $row->getSourceProperty('tid'); + // vocabulary machine name + $machine_name = $row->getSourceProperty('machine_name'); + $revid = $row->getSourceProperty('revision_id'); + + // Get Field API field values. + foreach ($this->getFields('taxonomy_term', $machine_name) as $field_name => $field) { + $row->setSourceProperty($field_name, $this->getFieldValues('taxonomy_term', $field_name, $tid, $revid, NULL)); + } + + // Find parents for this row. + $parents = $this->select('taxonomy_term_hierarchy', 'th') + ->fields('th', ['parent', 'tid']) + ->condition('tid', $row->getSourceProperty('tid')) + ->execute() + ->fetchCol(); + $row->setSourceProperty('parent', $parents); + + return parent::prepareRow($row); + } + + /** + * {@inheritdoc} + */ + public function getIds() { + $ids['tid']['type'] = 'integer'; + return $ids; + } + +}