BIG REFACTORING using composer create-project drupal-composer/drupal-project
This commit is contained in:
@@ -0,0 +1,48 @@
|
||||
# Every migration that references a file by Drupal 7 fid should specify this
|
||||
# migration as an optional dependency.
|
||||
id: d7_allpublicfiles
|
||||
label: Public files
|
||||
migration_group: d7_materio
|
||||
audit: true
|
||||
migration_tags:
|
||||
- Drupal 7
|
||||
- Content
|
||||
source:
|
||||
plugin: d7_file
|
||||
scheme: public
|
||||
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: '../../d7.materio.com/public_html'
|
||||
process:
|
||||
# If you are using this file to build a custom migration consider removing
|
||||
# the fid field to allow incremental migrations.
|
||||
fid: fid
|
||||
filename: filename
|
||||
source_full_path:
|
||||
-
|
||||
plugin: concat
|
||||
delimiter: /
|
||||
source:
|
||||
- constants/source_base_path
|
||||
- filepath
|
||||
-
|
||||
plugin: urlencode
|
||||
uri:
|
||||
plugin: file_copy
|
||||
source:
|
||||
- '@source_full_path'
|
||||
- uri
|
||||
filemime: filemime
|
||||
# No need to migrate filesize, it is computed when file entities are saved.
|
||||
# filesize: filesize
|
||||
status: status
|
||||
# Drupal 7 didn't keep track of the file's creation or update time -- all it
|
||||
# had was the vague "timestamp" column. So we'll use it for both.
|
||||
created: timestamp
|
||||
changed: timestamp
|
||||
uid: uid
|
||||
destination:
|
||||
plugin: entity:file
|
@@ -0,0 +1,97 @@
|
||||
id: d7_node_breve
|
||||
label: Node Breve
|
||||
migration_group: d7_materio
|
||||
audit: true
|
||||
migration_tags:
|
||||
- Drupal 7
|
||||
- Content
|
||||
- Materio
|
||||
deriver: Drupal\taxonomy\Plugin\migrate\D7TaxonomyTermDeriver
|
||||
|
||||
source:
|
||||
plugin: d7_node_breve
|
||||
node_type: breve
|
||||
|
||||
destination:
|
||||
plugin: entity:node
|
||||
|
||||
|
||||
process:
|
||||
# nid: nid
|
||||
type:
|
||||
plugin: default_value
|
||||
default_value: breve
|
||||
title: title
|
||||
field_migration:
|
||||
plugin: default_value
|
||||
default_value: 'migration_imported'
|
||||
body:
|
||||
plugin: iterator
|
||||
source: field_description
|
||||
process:
|
||||
value: value
|
||||
format:
|
||||
plugin: default_value
|
||||
default_value: wysiwyg
|
||||
langcode: language
|
||||
field_memo: field_memo
|
||||
field_workflow:
|
||||
-
|
||||
plugin: default_value
|
||||
source: workflow
|
||||
default_value: 2
|
||||
-
|
||||
plugin: static_map
|
||||
default_value: 2
|
||||
map:
|
||||
1: "workflow_creation"
|
||||
2: "workflow_hidden"
|
||||
3: "workflow_visible"
|
||||
4: "workflow_imported"
|
||||
5: "workflow_edited"
|
||||
field_thesaurus:
|
||||
plugin: migration_lookup
|
||||
migration: d7_taxonomy_term_thesaurus
|
||||
source: field_onthologie
|
||||
field_tags:
|
||||
plugin: migration_lookup
|
||||
migration: d7_taxonomy_term_tags
|
||||
source: field_tags_libres
|
||||
field_video:
|
||||
plugin: iterator
|
||||
source: field_video_filter
|
||||
process:
|
||||
value: url
|
||||
field_linked_materials:
|
||||
-
|
||||
plugin: skip_on_empty
|
||||
method: process
|
||||
source: linked_materials
|
||||
-
|
||||
plugin: migration_lookup
|
||||
migration: d7_node_materiau
|
||||
no_stub: true
|
||||
field_visuel:
|
||||
plugin: iterator
|
||||
source: field_visuel
|
||||
process:
|
||||
target_id:
|
||||
plugin: migration_lookup
|
||||
migration: d7_allpublicfiles
|
||||
source: fid
|
||||
no_stub: true
|
||||
alt: alt
|
||||
title: title
|
||||
height: height
|
||||
width: width
|
||||
|
||||
|
||||
migration_dependencies:
|
||||
required:
|
||||
- d7_allpublicfiles
|
||||
- d7_taxonomy_term_thesaurus
|
||||
- d7_taxonomy_term_tags
|
||||
- d7_taxonomy_term_company
|
||||
- d7_taxonomy_term_showroom
|
||||
optional:
|
||||
- d7_node_materiau
|
@@ -0,0 +1,43 @@
|
||||
id: d7_node_breve_i18n
|
||||
label: Node Breve i18n
|
||||
migration_group: d7_materio
|
||||
audit: true
|
||||
migration_tags:
|
||||
- Drupal 7
|
||||
- Content
|
||||
- Materio
|
||||
deriver: Drupal\node\Plugin\migrate\D7NodeDeriver
|
||||
|
||||
source:
|
||||
plugin: d7_node_breve_i18n
|
||||
node_type: breve
|
||||
translations: true
|
||||
|
||||
destination:
|
||||
plugin: entity:node
|
||||
translations: true
|
||||
|
||||
process:
|
||||
nid:
|
||||
plugin: migration_lookup
|
||||
source: nid
|
||||
migration: d7_node_breve
|
||||
no_stub: true
|
||||
type:
|
||||
plugin: default_value
|
||||
default_value: breve
|
||||
langcode: language
|
||||
content_translation_source: source
|
||||
title: title
|
||||
body:
|
||||
plugin: iterator
|
||||
source: body
|
||||
process:
|
||||
value: value
|
||||
format:
|
||||
plugin: default_value
|
||||
default_value: wysiwyg
|
||||
|
||||
migration_dependencies:
|
||||
required:
|
||||
- d7_node_breve
|
@@ -0,0 +1,147 @@
|
||||
id: d7_node_materiau
|
||||
label: Node Materiau
|
||||
migration_group: d7_materio
|
||||
audit: true
|
||||
migration_tags:
|
||||
- Drupal 7
|
||||
- Content
|
||||
- Materio
|
||||
# deriver: Drupal\taxonomy\Plugin\migrate\D7TaxonomyTermDeriver
|
||||
|
||||
source:
|
||||
plugin: d7_node_materiau
|
||||
node_type: materiau
|
||||
|
||||
destination:
|
||||
plugin: entity:node
|
||||
|
||||
|
||||
process:
|
||||
# nid: nid
|
||||
type:
|
||||
plugin: default_value
|
||||
default_value: materiau
|
||||
title: title
|
||||
field_short_description: field_nature_titre
|
||||
field_migration:
|
||||
plugin: default_value
|
||||
default_value: 'migration_imported'
|
||||
body:
|
||||
plugin: iterator
|
||||
source: field_description
|
||||
process:
|
||||
value: value
|
||||
format:
|
||||
plugin: default_value
|
||||
default_value: wysiwyg
|
||||
langcode: language
|
||||
field_memo: field_memo
|
||||
field_workflow:
|
||||
-
|
||||
plugin: default_value
|
||||
source: workflow
|
||||
default_value: 2
|
||||
-
|
||||
plugin: static_map
|
||||
default_value: 2
|
||||
map:
|
||||
1: "workflow_creation"
|
||||
2: "workflow_hidden"
|
||||
3: "workflow_visible"
|
||||
4: "workflow_imported"
|
||||
5: "workflow_edited"
|
||||
|
||||
field_thesaurus:
|
||||
plugin: migration_lookup
|
||||
migration: d7_taxonomy_term_thesaurus
|
||||
source: field_onthologie
|
||||
no_stub: true
|
||||
field_tags:
|
||||
plugin: migration_lookup
|
||||
migration: d7_taxonomy_term_tags
|
||||
source: field_tags_libres
|
||||
no_stub: true
|
||||
field_manufacturer:
|
||||
plugin: migration_lookup
|
||||
migration: d7_taxonomy_term_company
|
||||
source: field_company_fab
|
||||
no_stub: true
|
||||
field_distributor:
|
||||
plugin: migration_lookup
|
||||
migration: d7_taxonomy_term_company
|
||||
source: field_company_distrib
|
||||
no_stub: true
|
||||
field_video:
|
||||
plugin: iterator
|
||||
source: field_video_filter
|
||||
process:
|
||||
value: url
|
||||
field_linked_materials:
|
||||
-
|
||||
plugin: skip_on_empty
|
||||
method: process
|
||||
source: linked_materials
|
||||
-
|
||||
plugin: migration_lookup
|
||||
migration: d7_node_materiau
|
||||
no_stub: true
|
||||
field_linked_breves:
|
||||
-
|
||||
plugin: skip_on_empty
|
||||
method: process
|
||||
source: linked_breves
|
||||
-
|
||||
plugin: migration_lookup
|
||||
migration: d7_node_breve
|
||||
no_stub: true
|
||||
field_materiau_images:
|
||||
plugin: iterator
|
||||
source: field_materiau_image
|
||||
process:
|
||||
target_id:
|
||||
plugin: migration_lookup
|
||||
migration: d7_allpublicfiles
|
||||
source: fid
|
||||
no_stub: true
|
||||
alt: alt
|
||||
title: title
|
||||
height: height
|
||||
width: width
|
||||
field_attachments:
|
||||
plugin: iterator
|
||||
source: field_attachments
|
||||
process:
|
||||
target_id:
|
||||
plugin: migration_lookup
|
||||
migration: d7_allpublicfiles
|
||||
source: fid
|
||||
no_stub: true
|
||||
# there is no description field filled
|
||||
description: description
|
||||
field_famille: field_famille
|
||||
field_index: field_identifiant
|
||||
field_reference: field_reference_materio
|
||||
# just archives
|
||||
field_localisation_old: field_localisation
|
||||
# custom module rebuilded
|
||||
field_samples:
|
||||
plugin: iterator
|
||||
source: field_location
|
||||
process:
|
||||
location: location
|
||||
target_id:
|
||||
plugin: migration_lookup
|
||||
migration: d7_taxonomy_term_showroom
|
||||
source: showroom_tid
|
||||
no_stub: true
|
||||
|
||||
|
||||
migration_dependencies:
|
||||
required:
|
||||
- d7_allpublicfiles
|
||||
- d7_taxonomy_term_thesaurus
|
||||
- d7_taxonomy_term_tags
|
||||
- d7_taxonomy_term_company
|
||||
- d7_taxonomy_term_showroom
|
||||
optional:
|
||||
- d7_node_breve
|
@@ -0,0 +1,44 @@
|
||||
id: d7_node_materiau_i18n
|
||||
label: Node Materiau i18n
|
||||
migration_group: d7_materio
|
||||
audit: true
|
||||
migration_tags:
|
||||
- Drupal 7
|
||||
- Content
|
||||
- Materio
|
||||
deriver: Drupal\node\Plugin\migrate\D7NodeDeriver
|
||||
|
||||
source:
|
||||
plugin: d7_node_materiau_i18n
|
||||
node_type: materiau
|
||||
translations: true
|
||||
|
||||
destination:
|
||||
plugin: entity:node
|
||||
translations: true
|
||||
|
||||
process:
|
||||
nid:
|
||||
plugin: migration_lookup
|
||||
source: nid
|
||||
migration: d7_node_materiau
|
||||
no_stub: true
|
||||
type:
|
||||
plugin: default_value
|
||||
default_value: materiau
|
||||
langcode: language
|
||||
content_translation_source: source
|
||||
title: title
|
||||
field_short_description: field_nature_titre
|
||||
body:
|
||||
plugin: iterator
|
||||
source: field_description
|
||||
process:
|
||||
value: value
|
||||
format:
|
||||
plugin: default_value
|
||||
default_value: wysiwyg
|
||||
|
||||
migration_dependencies:
|
||||
required:
|
||||
- d7_node_materiau
|
@@ -0,0 +1,129 @@
|
||||
id: d7_taxonomy_term_company
|
||||
label: Taxonomy terms Company
|
||||
migration_group: d7_materio
|
||||
audit: true
|
||||
migration_tags:
|
||||
- Drupal 7
|
||||
- Content
|
||||
- Materio
|
||||
deriver: Drupal\taxonomy\Plugin\migrate\D7TaxonomyTermDeriver
|
||||
|
||||
source:
|
||||
plugin: d7_taxonomy_term_company
|
||||
bundle: company
|
||||
|
||||
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: company
|
||||
name: name
|
||||
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_companie
|
||||
parent:
|
||||
plugin: default_value
|
||||
default_value: 0
|
||||
source: '@parent_id'
|
||||
changed: timestamp
|
||||
langcode:
|
||||
plugin: default_value
|
||||
default_value: 'und'
|
||||
field_migration:
|
||||
plugin: default_value
|
||||
default_value: 'migration_imported'
|
||||
|
||||
# FROM TODE (linked tode node)
|
||||
field_website:
|
||||
plugin: iterator
|
||||
source: field_website
|
||||
process:
|
||||
uri: url
|
||||
title: title
|
||||
options: attributes
|
||||
field_memo: field_memo
|
||||
field_public_phone: public_phone
|
||||
field_public_email:
|
||||
plugin: iterator
|
||||
source: field_public_email
|
||||
process:
|
||||
value: email
|
||||
field_public_address:
|
||||
plugin: iterator
|
||||
source: field_public_address
|
||||
process:
|
||||
# langcode:
|
||||
country_code: country
|
||||
administrative_area: administrative_area
|
||||
locality: locality
|
||||
dependent_locality: dependent_locality
|
||||
postal_code: postal_code
|
||||
# sorting_code:
|
||||
address_line1: thoroughfare
|
||||
# address_line2:
|
||||
organization: organisation_name
|
||||
given_name: first_name
|
||||
# additional_name:
|
||||
family_name: last_name
|
||||
|
||||
# SOURCES
|
||||
# sub_administrative_area
|
||||
# premise
|
||||
# sub_premise
|
||||
# name_line
|
||||
# data
|
||||
|
||||
field_note: field_note
|
||||
field_departement: field_departement
|
||||
description:
|
||||
plugin: iterator
|
||||
source: body
|
||||
process:
|
||||
value: value
|
||||
format:
|
||||
plugin: default_value
|
||||
default_value: wysiwyg
|
||||
field_infos_from_company:
|
||||
plugin: iterator
|
||||
source: field_infos_from_company
|
||||
process:
|
||||
value: value
|
||||
format:
|
||||
plugin: default_value
|
||||
default_value: wysiwyg
|
||||
field_workflow:
|
||||
plugin: static_map
|
||||
source: workflow
|
||||
map:
|
||||
1: "workflow_creation"
|
||||
2: "workflow_hidden"
|
||||
3: "workflow_visible"
|
||||
4: "workflow_imported"
|
||||
5: "workflow_edited"
|
||||
field_attachments:
|
||||
plugin: iterator
|
||||
source: field_attachments
|
||||
process:
|
||||
target_id:
|
||||
plugin: migration_lookup
|
||||
migration: d7_allpublicfiles
|
||||
source: fid
|
||||
no_stub: true
|
||||
# there is no description field filled
|
||||
description: description
|
||||
|
||||
migration_dependencies:
|
||||
required:
|
||||
- d7_allpublicfiles
|
@@ -0,0 +1,87 @@
|
||||
id: d7_taxonomy_term_showroom
|
||||
label: Taxonomy terms Showroom
|
||||
migration_group: d7_materio
|
||||
audit: true
|
||||
migration_tags:
|
||||
- Drupal 7
|
||||
- Content
|
||||
- Materio
|
||||
deriver: Drupal\taxonomy\Plugin\migrate\D7TaxonomyTermDeriver
|
||||
|
||||
source:
|
||||
plugin: d7_taxonomy_term_showroom
|
||||
bundle: showroom
|
||||
|
||||
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: showroom
|
||||
name: name
|
||||
weight: weight
|
||||
parent:
|
||||
plugin: default_value
|
||||
default_value: 0
|
||||
changed: timestamp
|
||||
langcode:
|
||||
plugin: default_value
|
||||
default_value: 'und'
|
||||
field_migration:
|
||||
plugin: default_value
|
||||
default_value: 'migration_imported'
|
||||
field_workflow:
|
||||
plugin: default_value
|
||||
default_value: 'workflow_visible'
|
||||
|
||||
# tode node showroom
|
||||
field_website:
|
||||
plugin: iterator
|
||||
source: field_website
|
||||
process:
|
||||
uri: url
|
||||
title: title
|
||||
options: attributes
|
||||
field_memo: field_memo
|
||||
field_public_phone: public_phone
|
||||
field_public_email:
|
||||
plugin: iterator
|
||||
source: field_public_email
|
||||
process:
|
||||
value: email
|
||||
field_public_address:
|
||||
plugin: iterator
|
||||
source: field_public_address
|
||||
process:
|
||||
# langcode:
|
||||
country_code: country
|
||||
administrative_area: administrative_area
|
||||
locality: locality
|
||||
dependent_locality: dependent_locality
|
||||
postal_code: postal_code
|
||||
# sorting_code:
|
||||
address_line1: thoroughfare
|
||||
# address_line2:
|
||||
organization: organisation_name
|
||||
given_name: first_name
|
||||
# additional_name:
|
||||
family_name: last_name
|
||||
|
||||
# SOURCES
|
||||
# sub_administrative_area
|
||||
# premise
|
||||
# sub_premise
|
||||
# name_line
|
||||
# data
|
||||
description:
|
||||
plugin: iterator
|
||||
source: body
|
||||
process:
|
||||
value: value
|
||||
format:
|
||||
plugin: default_value
|
||||
default_value: wysiwyg
|
@@ -0,0 +1,48 @@
|
||||
id: d7_taxonomy_term_tags
|
||||
label: Taxonomy terms Tags
|
||||
migration_group: d7_materio
|
||||
audit: true
|
||||
migration_tags:
|
||||
- Drupal 7
|
||||
- Content
|
||||
- Materio
|
||||
deriver: Drupal\taxonomy\Plugin\migrate\D7TaxonomyTermDeriver
|
||||
|
||||
source:
|
||||
plugin: d7_taxonomy_term_tags
|
||||
bundle: tag_libres
|
||||
|
||||
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: tags
|
||||
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_tags
|
||||
parent:
|
||||
plugin: default_value
|
||||
default_value: 0
|
||||
source: '@parent_id'
|
||||
changed: timestamp
|
||||
|
||||
#synonyms
|
||||
field_synonyms: synonyms_synonym
|
||||
|
||||
# used on advanced search
|
||||
# field_used_on_advanced_search: field_used_on_advanced_search
|
@@ -0,0 +1,39 @@
|
||||
id: d7_taxonomy_term_tags_i18n
|
||||
label: Taxonomy terms Tags i18n
|
||||
migration_group: d7_materio
|
||||
audit: true
|
||||
migration_tags:
|
||||
- Drupal 7
|
||||
- Content
|
||||
- Materio
|
||||
deriver: Drupal\taxonomy\Plugin\migrate\D7TaxonomyTermDeriver
|
||||
|
||||
source:
|
||||
plugin: d7_taxonomy_term_tags_i18n
|
||||
bundle: tag_libres
|
||||
translations: true
|
||||
|
||||
destination:
|
||||
plugin: entity:taxonomy_term
|
||||
translations: true
|
||||
|
||||
process:
|
||||
tid:
|
||||
plugin: migration_lookup
|
||||
migration: d7_taxonomy_term_tags
|
||||
source: tid
|
||||
vid:
|
||||
plugin: default_value
|
||||
default_value: tags
|
||||
langcode: language
|
||||
|
||||
name: name
|
||||
|
||||
'description/value': description
|
||||
'description/format': format
|
||||
|
||||
field_synonyms: synonyms_synonym
|
||||
|
||||
migration_dependencies:
|
||||
required:
|
||||
- d7_taxonomy_term_tags
|
@@ -0,0 +1,48 @@
|
||||
id: d7_taxonomy_term_thesaurus
|
||||
label: Taxonomy terms Thesaurus
|
||||
migration_group: d7_materio
|
||||
audit: true
|
||||
migration_tags:
|
||||
- Drupal 7
|
||||
- Content
|
||||
- Materio
|
||||
deriver: Drupal\taxonomy\Plugin\migrate\D7TaxonomyTermDeriver
|
||||
|
||||
source:
|
||||
plugin: d7_taxonomy_term_thesaurus
|
||||
bundle: onthologie
|
||||
|
||||
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: thesaurus
|
||||
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_thesaurus
|
||||
parent:
|
||||
plugin: default_value
|
||||
default_value: 0
|
||||
source: '@parent_id'
|
||||
changed: timestamp
|
||||
|
||||
#synonyms
|
||||
field_synonyms: synonyms_synonym
|
||||
|
||||
# used on advanced search
|
||||
field_used_on_advanced_search: field_used_on_advanced_search
|
@@ -0,0 +1,39 @@
|
||||
id: d7_taxonomy_term_thesaurus_i18n
|
||||
label: Taxonomy terms Thesaurus i18n
|
||||
migration_group: d7_materio
|
||||
audit: true
|
||||
migration_tags:
|
||||
- Drupal 7
|
||||
- Content
|
||||
- Materio
|
||||
deriver: Drupal\taxonomy\Plugin\migrate\D7TaxonomyTermDeriver
|
||||
|
||||
source:
|
||||
plugin: d7_taxonomy_term_thesaurus_i18n
|
||||
bundle: onthologie
|
||||
translations: true
|
||||
|
||||
destination:
|
||||
plugin: entity:taxonomy_term
|
||||
translations: true
|
||||
|
||||
process:
|
||||
tid:
|
||||
plugin: migration_lookup
|
||||
migration: d7_taxonomy_term_thesaurus
|
||||
source: tid
|
||||
vid:
|
||||
plugin: default_value
|
||||
default_value: thesaurus
|
||||
langcode: language
|
||||
|
||||
name: name
|
||||
|
||||
'description/value': description
|
||||
'description/format': format
|
||||
|
||||
field_synonyms: synonyms_synonym
|
||||
|
||||
migration_dependencies:
|
||||
required:
|
||||
- d7_taxonomy_term_thesaurus
|
@@ -0,0 +1,11 @@
|
||||
id: d7_materio
|
||||
label: D7 Materio
|
||||
description: Drupal 7 materio content migration to Drupal 8.
|
||||
source_type: Drupal 7
|
||||
shared_configuration:
|
||||
source:
|
||||
key: legacy
|
||||
dependencies:
|
||||
enforced:
|
||||
module:
|
||||
- materio_migrate
|
23
web/modules/custom/materio_migrate/materio_migrate.info.yml
Normal file
23
web/modules/custom/materio_migrate/materio_migrate.info.yml
Normal file
@@ -0,0 +1,23 @@
|
||||
name: Materio Migration
|
||||
type: module
|
||||
description: Defines custom migration for materio (from d7 to d8).
|
||||
core: 8.x
|
||||
package: Materio
|
||||
dependencies:
|
||||
- config_devel
|
||||
- drupal:migrate
|
||||
- drupal:migrate_drupal
|
||||
- drupal:migrate_drupal_multilingual
|
||||
- migrate_plus:migrate_plus
|
||||
- migrate_tools:migrate_tools
|
||||
# - drupal:field_group_migrate
|
||||
- telephone_validation
|
||||
|
||||
config_devel:
|
||||
install:
|
||||
- migrate_plus.migration_group.d7_materio
|
||||
- migrate_plus.migration.d7_taxonomy_term_thesaurus
|
||||
- migrate_plus.migration.d7_taxonomy_term_tags
|
||||
- migrate_plus.migration.d7_taxonomy_term_showroom
|
||||
- migrate_plus.migration.d7_taxonomy_term_company
|
||||
- migrate_plus.migration.d7_node_entity_translation_materiau
|
37
web/modules/custom/materio_migrate/readme.md
Normal file
37
web/modules/custom/materio_migrate/readme.md
Normal file
@@ -0,0 +1,37 @@
|
||||
[debugging-migrations](https://www.drupal.org/docs/8/api/migrate-api/debugging-migrations)
|
||||
|
||||
https://www.drupaleasy.com/blogs/ultimike/2016/04/drupal-6-drupal-81x-custom-content-migration
|
||||
|
||||
https://thinkshout.com/blog/2017/05/skipping-a-version-migrating-from-drupal-6-to-drupal-8-with-drupal-migrate/
|
||||
|
||||
https://www.drupal.org/docs/8/upgrade/known-issues-when-upgrading-from-drupal-6-or-7-to-drupal-8
|
||||
|
||||
https://drupal.stackexchange.com/questions/164612/how-do-i-remove-a-configuration-object-from-the-active-configuration
|
||||
|
||||
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)
|
||||
|
||||
[Migrating Aliases and Redirects to Drupal 8](https://evolvingweb.ca/blog/migrating-aliases-and-redirects-drupal-8)
|
||||
|
||||
[Migrating Drupal 7 redirects to Drupal 8](http://activelamp.com/blog/drupal/migrating-drupal-8-redirects/)
|
||||
|
||||
[How to refresh new migrations in Drupal 8 migration module?](https://drupal.stackexchange.com/questions/191435/how-to-refresh-new-migrations-in-drupal-8-migration-module)
|
||||
|
||||
[Drupal 8 Migrations: Taxonomy and Nodes](https://www.phase2technology.com/blog/drupal-8-migrations)
|
||||
|
||||
[Migrating Content Translated with "Content Translation" from Drupal 7 to Drupal 8](https://evolvingweb.ca/blog/migrating-content-translated-content-translation-drupal-7-drupal-8)
|
||||
|
||||
[Drupal 8 Migration Survival Strategies](http://pnijjar.freeshell.org/2017/drupal8-migrate/)
|
@@ -0,0 +1,229 @@
|
||||
<?php
|
||||
|
||||
namespace Drupal\materio_migrate\Plugin\migrate\source;
|
||||
|
||||
use Drupal\Core\Extension\ModuleHandlerInterface;
|
||||
use Drupal\migrate\Row;
|
||||
use Drupal\migrate_drupal\Plugin\migrate\source\d7\FieldableEntity;
|
||||
use Drupal\Core\Database\Query\SelectInterface;
|
||||
use Drupal\Core\Entity\EntityManagerInterface;
|
||||
use Drupal\Core\Extension\ModuleHandler;
|
||||
use Drupal\Core\State\StateInterface;
|
||||
use Drupal\migrate\Plugin\MigrationInterface;
|
||||
use Symfony\Component\DependencyInjection\ContainerInterface;
|
||||
|
||||
/**
|
||||
* Drupal 7 node source from database.
|
||||
*
|
||||
* @MigrateSource(
|
||||
* id = "d7_node_breve",
|
||||
* source_module = "node"
|
||||
* )
|
||||
*/
|
||||
class D7NodeBreve extends FieldableEntity {
|
||||
/**
|
||||
* The module handler.
|
||||
*
|
||||
* @var \Drupal\Core\Extension\ModuleHandlerInterface
|
||||
*/
|
||||
protected $moduleHandler;
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function __construct(array $configuration, $plugin_id, $plugin_definition, MigrationInterface $migration, StateInterface $state, EntityManagerInterface $entity_manager, ModuleHandlerInterface $module_handler) {
|
||||
parent::__construct($configuration, $plugin_id, $plugin_definition, $migration, $state, $entity_manager);
|
||||
$this->moduleHandler = $module_handler;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public static function create(ContainerInterface $container, array $configuration, $plugin_id, $plugin_definition, MigrationInterface $migration = NULL) {
|
||||
return new static(
|
||||
$configuration,
|
||||
$plugin_id,
|
||||
$plugin_definition,
|
||||
$migration,
|
||||
$container->get('state'),
|
||||
$container->get('entity.manager'),
|
||||
$container->get('module_handler')
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* The join options between the node and the node_revisions table.
|
||||
*/
|
||||
const JOIN = 'n.vid = nr.vid';
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function query() {
|
||||
// Select node in its last revision.
|
||||
$query = $this->select('node_revision', 'nr')
|
||||
->fields('n', [
|
||||
'nid',
|
||||
'type',
|
||||
'language',
|
||||
'status',
|
||||
'created',
|
||||
'changed',
|
||||
'comment',
|
||||
'promote',
|
||||
'sticky',
|
||||
'tnid',
|
||||
'translate',
|
||||
])
|
||||
->fields('nr', [
|
||||
'vid',
|
||||
'title',
|
||||
'log',
|
||||
'timestamp',
|
||||
])
|
||||
->orderBy('nid');
|
||||
|
||||
$query->addField('n', 'uid', 'node_uid');
|
||||
$query->addField('nr', 'uid', 'revision_uid');
|
||||
$query->innerJoin('node', 'n', static::JOIN);
|
||||
|
||||
// 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');
|
||||
}
|
||||
$this->handleTranslations($query);
|
||||
|
||||
if (isset($this->configuration['node_type'])) {
|
||||
$query->condition('n.type', $this->configuration['node_type']);
|
||||
}
|
||||
|
||||
return $query;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function prepareRow(Row $row) {
|
||||
$nid = $row->getSourceProperty('nid');
|
||||
$vid = $row->getSourceProperty('vid');
|
||||
$type = $row->getSourceProperty('type');
|
||||
$title = $row->getSourceProperty('title');
|
||||
// drush_print('-- '.$nid."\t".$title);
|
||||
|
||||
// If this entity was translated using Entity Translation, we need to get
|
||||
// its source language to get the field values in the right language.
|
||||
// The translations will be migrated by the d7_node_entity_translation
|
||||
// migration.
|
||||
$entity_translatable = $this->isEntityTranslatable('node') && (int) $this->variableGet('language_content_type_' . $type, 0) === 4;
|
||||
$language = $entity_translatable ? $this->getEntityTranslationSourceLanguage('node', $nid) : $row->getSourceProperty('language');
|
||||
|
||||
// Get Field API field values.
|
||||
foreach ($this->getFields('node', $type) as $field_name => $field) {
|
||||
// Ensure we're using the right language if the entity and the field are
|
||||
// translatable.
|
||||
$field_language = $entity_translatable && $field['translatable'] ? $language : NULL;
|
||||
$row->setSourceProperty($field_name, $this->getFieldValues('node', $field_name, $nid, $vid, $field_language));
|
||||
}
|
||||
|
||||
// linked materials
|
||||
$linked_materials = [];
|
||||
if(!empty($row->getSourceProperty('field_materiau_ref'))){
|
||||
// print_r($row->getSourceProperty('field_materiau_ref'));
|
||||
foreach ($row->getSourceProperty('field_materiau_ref') as $key => $value) {
|
||||
$linked_materials[] = $value['target_id'];
|
||||
}
|
||||
// print_r($linked_materials);
|
||||
}
|
||||
$row->setSourceProperty('linked_materials', $linked_materials);
|
||||
|
||||
// Make sure we always have a translation set.
|
||||
if ($row->getSourceProperty('tnid') == 0) {
|
||||
$row->setSourceProperty('tnid', $row->getSourceProperty('nid'));
|
||||
}
|
||||
|
||||
// If the node title was replaced by a real field using the Drupal 7 Title
|
||||
// module, use the field value instead of the node title.
|
||||
if ($this->moduleExists('title')) {
|
||||
$title_field = $row->getSourceProperty('title_field');
|
||||
if (isset($title_field[0]['value'])) {
|
||||
$row->setSourceProperty('title', $title_field[0]['value']);
|
||||
}
|
||||
}
|
||||
|
||||
// workflow
|
||||
$query = $this->select('workflow_node', 'wn');
|
||||
$query->fields('wn', ['sid']);
|
||||
$query->condition('wn.nid', $nid);
|
||||
$results = $query->execute()->fetchField();
|
||||
if(!$results){
|
||||
$results = 2;
|
||||
// add bad workflow to memo field
|
||||
$memo .= "#migration : invalid workflow\n";
|
||||
drush_print('WARNING: no workflow');
|
||||
}
|
||||
$row->setSourceProperty('workflow', $results);
|
||||
|
||||
|
||||
// record migration errors in field_memo
|
||||
if(isset($memo)){
|
||||
$field_memo = $row->getSourceProperty('field_memo');
|
||||
$field_memo[0]['value'] .= "\n".$memo;
|
||||
$row->setSourceProperty('field_memo', $field_memo);
|
||||
}
|
||||
|
||||
return parent::prepareRow($row);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function fields() {
|
||||
$fields = [
|
||||
'nid' => $this->t('Node ID'),
|
||||
'type' => $this->t('Type'),
|
||||
'title' => $this->t('Title'),
|
||||
'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 getIds() {
|
||||
$ids['nid']['type'] = 'integer';
|
||||
$ids['nid']['alias'] = 'n';
|
||||
return $ids;
|
||||
}
|
||||
|
||||
/**
|
||||
* Adapt our query for translations.
|
||||
*
|
||||
* @param \Drupal\Core\Database\Query\SelectInterface $query
|
||||
* The generated query.
|
||||
*/
|
||||
protected function handleTranslations(SelectInterface $query) {
|
||||
// Check whether or not we want translations.
|
||||
if (empty($this->configuration['translations'])) {
|
||||
// No translations: Yield untranslated nodes, or default translations.
|
||||
$query->where('n.tnid = 0 OR n.tnid = n.nid');
|
||||
}
|
||||
else {
|
||||
// Translations: Yield only non-default translations.
|
||||
$query->where('n.tnid <> 0 AND n.tnid <> n.nid');
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@@ -0,0 +1,128 @@
|
||||
<?php
|
||||
|
||||
namespace Drupal\materio_migrate\Plugin\migrate\source;
|
||||
|
||||
use Drupal\migrate\Row;
|
||||
use Drupal\migrate_drupal\Plugin\migrate\source\d7\FieldableEntity;
|
||||
|
||||
/**
|
||||
* Provides Drupal 7 node entity translations source plugin.
|
||||
*
|
||||
* @MigrateSource(
|
||||
* id = "d7_node_breve_i18n",
|
||||
* source_module = "entity_translation"
|
||||
* )
|
||||
*/
|
||||
class D7NodeBreveI18n extends FieldableEntity {
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function query() {
|
||||
$query = $this->select('entity_translation', 'et')
|
||||
->fields('et', [
|
||||
'entity_id',
|
||||
'revision_id',
|
||||
'language',
|
||||
'source',
|
||||
'uid',
|
||||
'status',
|
||||
'created',
|
||||
'changed',
|
||||
])
|
||||
->fields('n', [
|
||||
'nid',
|
||||
'title',
|
||||
'type',
|
||||
'promote',
|
||||
'sticky',
|
||||
])
|
||||
->fields('nr', [
|
||||
'log',
|
||||
'timestamp',
|
||||
])
|
||||
->condition('et.entity_type', 'node')
|
||||
->condition('et.source', '', '<>');
|
||||
|
||||
$query->addField('nr', 'uid', 'revision_uid');
|
||||
|
||||
$query->innerJoin('node', 'n', 'n.nid = et.entity_id');
|
||||
$query->innerJoin('node_revision', 'nr', 'nr.vid = et.revision_id');
|
||||
|
||||
if (isset($this->configuration['node_type'])) {
|
||||
$query->condition('n.type', $this->configuration['node_type']);
|
||||
}
|
||||
|
||||
return $query;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function prepareRow(Row $row) {
|
||||
$nid = $row->getSourceProperty('entity_id');
|
||||
$vid = $row->getSourceProperty('revision_id');
|
||||
$type = $row->getSourceProperty('type');
|
||||
$language = $row->getSourceProperty('language');
|
||||
$title = $row->getSourceProperty('title');
|
||||
// drush_print('-- '.$nid."\t".$title."\t".$language);
|
||||
|
||||
// Get Field API field values.
|
||||
foreach ($this->getFields('node', $type) as $field_name => $field) {
|
||||
// Ensure we're using the right language if the entity is translatable.
|
||||
$field_language = $field['translatable'] ? $language : NULL;
|
||||
$row->setSourceProperty($field_name, $this->getFieldValues('node', $field_name, $nid, $vid, $field_language));
|
||||
}
|
||||
|
||||
// If the node title was replaced by a real field using the Drupal 7 Title
|
||||
// module, use the field value instead of the node title.
|
||||
if ($this->moduleExists('title')) {
|
||||
$title_field = $row->getSourceProperty('title_field');
|
||||
if (isset($title_field[0]['value'])) {
|
||||
$row->setSourceProperty('title', $title_field[0]['value']);
|
||||
}
|
||||
}
|
||||
|
||||
return parent::prepareRow($row);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function fields() {
|
||||
return [
|
||||
'entity_id' => $this->t('Entity ID'),
|
||||
'revision_id' => $this->t('Revision ID'),
|
||||
'language' => $this->t('Node translation language'),
|
||||
'source' => $this->t('Node translation source language'),
|
||||
'uid' => $this->t('Node translation authored by (uid)'),
|
||||
'status' => $this->t('Published'),
|
||||
'created' => $this->t('Created timestamp'),
|
||||
'changed' => $this->t('Modified timestamp'),
|
||||
'title' => $this->t('Node title'),
|
||||
'type' => $this->t('Node type'),
|
||||
'promote' => $this->t('Promoted to front page'),
|
||||
'sticky' => $this->t('Sticky at top of lists'),
|
||||
'log' => $this->t('Revision log'),
|
||||
'timestamp' => $this->t('The timestamp the latest revision of this node was created.'),
|
||||
'revision_uid' => $this->t('Revision authored by (uid)'),
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getIds() {
|
||||
return [
|
||||
'entity_id' => [
|
||||
'type' => 'integer',
|
||||
'alias' => 'et',
|
||||
],
|
||||
'language' => [
|
||||
'type' => 'string',
|
||||
'alias' => 'et',
|
||||
],
|
||||
];
|
||||
}
|
||||
|
||||
}
|
@@ -0,0 +1,242 @@
|
||||
<?php
|
||||
|
||||
namespace Drupal\materio_migrate\Plugin\migrate\source;
|
||||
|
||||
use Drupal\Core\Extension\ModuleHandlerInterface;
|
||||
use Drupal\migrate\Row;
|
||||
use Drupal\migrate_drupal\Plugin\migrate\source\d7\FieldableEntity;
|
||||
use Drupal\Core\Database\Query\SelectInterface;
|
||||
use Drupal\Core\Entity\EntityManagerInterface;
|
||||
use Drupal\Core\Extension\ModuleHandler;
|
||||
use Drupal\Core\State\StateInterface;
|
||||
use Drupal\migrate\Plugin\MigrationInterface;
|
||||
use Symfony\Component\DependencyInjection\ContainerInterface;
|
||||
|
||||
/**
|
||||
* Drupal 7 node source from database.
|
||||
*
|
||||
* @MigrateSource(
|
||||
* id = "d7_node_materiau",
|
||||
* source_module = "node"
|
||||
* )
|
||||
*/
|
||||
class D7NodeMateriau extends FieldableEntity {
|
||||
/**
|
||||
* The module handler.
|
||||
*
|
||||
* @var \Drupal\Core\Extension\ModuleHandlerInterface
|
||||
*/
|
||||
protected $moduleHandler;
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function __construct(array $configuration, $plugin_id, $plugin_definition, MigrationInterface $migration, StateInterface $state, EntityManagerInterface $entity_manager, ModuleHandlerInterface $module_handler) {
|
||||
parent::__construct($configuration, $plugin_id, $plugin_definition, $migration, $state, $entity_manager);
|
||||
$this->moduleHandler = $module_handler;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public static function create(ContainerInterface $container, array $configuration, $plugin_id, $plugin_definition, MigrationInterface $migration = NULL) {
|
||||
return new static(
|
||||
$configuration,
|
||||
$plugin_id,
|
||||
$plugin_definition,
|
||||
$migration,
|
||||
$container->get('state'),
|
||||
$container->get('entity.manager'),
|
||||
$container->get('module_handler')
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* The join options between the node and the node_revisions table.
|
||||
*/
|
||||
const JOIN = 'n.vid = nr.vid';
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function query() {
|
||||
// Select node in its last revision.
|
||||
$query = $this->select('node_revision', 'nr')
|
||||
->fields('n', [
|
||||
'nid',
|
||||
'type',
|
||||
'language',
|
||||
'status',
|
||||
'created',
|
||||
'changed',
|
||||
'comment',
|
||||
'promote',
|
||||
'sticky',
|
||||
'tnid',
|
||||
'translate',
|
||||
])
|
||||
->fields('nr', [
|
||||
'vid',
|
||||
'title',
|
||||
'log',
|
||||
'timestamp',
|
||||
])
|
||||
->orderBy('nid');
|
||||
|
||||
$query->addField('n', 'uid', 'node_uid');
|
||||
$query->addField('nr', 'uid', 'revision_uid');
|
||||
$query->innerJoin('node', 'n', static::JOIN);
|
||||
|
||||
// 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');
|
||||
}
|
||||
$this->handleTranslations($query);
|
||||
|
||||
if (isset($this->configuration['node_type'])) {
|
||||
$query->condition('n.type', $this->configuration['node_type']);
|
||||
}
|
||||
|
||||
return $query;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function prepareRow(Row $row) {
|
||||
$nid = $row->getSourceProperty('nid');
|
||||
$vid = $row->getSourceProperty('vid');
|
||||
$type = $row->getSourceProperty('type');
|
||||
$title = $row->getSourceProperty('title');
|
||||
// drush_print('-- '.$nid."\t".$title);
|
||||
|
||||
// If this entity was translated using Entity Translation, we need to get
|
||||
// its source language to get the field values in the right language.
|
||||
// The translations will be migrated by the d7_node_entity_translation
|
||||
// migration.
|
||||
$entity_translatable = $this->isEntityTranslatable('node') && (int) $this->variableGet('language_content_type_' . $type, 0) === 4;
|
||||
$language = $entity_translatable ? $this->getEntityTranslationSourceLanguage('node', $nid) : $row->getSourceProperty('language');
|
||||
|
||||
// Get Field API field values.
|
||||
foreach ($this->getFields('node', $type) as $field_name => $field) {
|
||||
// Ensure we're using the right language if the entity and the field are
|
||||
// translatable.
|
||||
$field_language = $entity_translatable && $field['translatable'] ? $language : NULL;
|
||||
$row->setSourceProperty($field_name, $this->getFieldValues('node', $field_name, $nid, $vid, $field_language));
|
||||
}
|
||||
|
||||
// linked materials
|
||||
$linked_materials = [];
|
||||
if(!empty($row->getSourceProperty('field_materiau_ref'))){
|
||||
// print_r($row->getSourceProperty('field_materiau_ref'));
|
||||
foreach ($row->getSourceProperty('field_materiau_ref') as $key => $value) {
|
||||
$linked_materials[] = $value['target_id'];
|
||||
}
|
||||
// print_r($linked_materials);
|
||||
}
|
||||
$row->setSourceProperty('linked_materials', $linked_materials);
|
||||
|
||||
//linked breves
|
||||
$linked_breves = [];
|
||||
if(!empty($row->getSourceProperty('field_breve_ref'))){
|
||||
foreach ($row->getSourceProperty('field_breve_ref') as $key => $value) {
|
||||
$linked_breves[] = $value['target_id'];
|
||||
}
|
||||
}
|
||||
$row->setSourceProperty('linked_breves', $linked_breves);
|
||||
|
||||
// print_r($row->getSourceProperty('field_identifiant'));
|
||||
// print_r($row->getSourceProperty('field_reference_materio'));
|
||||
|
||||
|
||||
// Make sure we always have a translation set.
|
||||
if ($row->getSourceProperty('tnid') == 0) {
|
||||
$row->setSourceProperty('tnid', $row->getSourceProperty('nid'));
|
||||
}
|
||||
|
||||
// If the node title was replaced by a real field using the Drupal 7 Title
|
||||
// module, use the field value instead of the node title.
|
||||
if ($this->moduleExists('title')) {
|
||||
$title_field = $row->getSourceProperty('title_field');
|
||||
if (isset($title_field[0]['value'])) {
|
||||
$row->setSourceProperty('title', $title_field[0]['value']);
|
||||
}
|
||||
}
|
||||
|
||||
// workflow
|
||||
$query = $this->select('workflow_node', 'wn');
|
||||
$query->fields('wn', ['sid']);
|
||||
$query->condition('wn.nid', $nid);
|
||||
$results = $query->execute()->fetchField();
|
||||
if(!$results){
|
||||
$results = 2;
|
||||
// add bad workflow to memo field
|
||||
$memo .= "#migration : invalid workflow\n";
|
||||
drush_print('WARNING: no workflow');
|
||||
}
|
||||
$row->setSourceProperty('workflow', $results);
|
||||
|
||||
|
||||
// record migration errors in field_memo
|
||||
if(isset($memo)){
|
||||
$field_memo = $row->getSourceProperty('field_memo');
|
||||
$field_memo[0]['value'] .= "\n".$memo;
|
||||
$row->setSourceProperty('field_memo', $field_memo);
|
||||
}
|
||||
|
||||
return parent::prepareRow($row);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function fields() {
|
||||
$fields = [
|
||||
'nid' => $this->t('Node ID'),
|
||||
'type' => $this->t('Type'),
|
||||
'title' => $this->t('Title'),
|
||||
'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 getIds() {
|
||||
$ids['nid']['type'] = 'integer';
|
||||
$ids['nid']['alias'] = 'n';
|
||||
return $ids;
|
||||
}
|
||||
|
||||
/**
|
||||
* Adapt our query for translations.
|
||||
*
|
||||
* @param \Drupal\Core\Database\Query\SelectInterface $query
|
||||
* The generated query.
|
||||
*/
|
||||
protected function handleTranslations(SelectInterface $query) {
|
||||
// Check whether or not we want translations.
|
||||
if (empty($this->configuration['translations'])) {
|
||||
// No translations: Yield untranslated nodes, or default translations.
|
||||
$query->where('n.tnid = 0 OR n.tnid = n.nid');
|
||||
}
|
||||
else {
|
||||
// Translations: Yield only non-default translations.
|
||||
$query->where('n.tnid <> 0 AND n.tnid <> n.nid');
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@@ -0,0 +1,128 @@
|
||||
<?php
|
||||
|
||||
namespace Drupal\materio_migrate\Plugin\migrate\source;
|
||||
|
||||
use Drupal\migrate\Row;
|
||||
use Drupal\migrate_drupal\Plugin\migrate\source\d7\FieldableEntity;
|
||||
|
||||
/**
|
||||
* Provides Drupal 7 node entity translations source plugin.
|
||||
*
|
||||
* @MigrateSource(
|
||||
* id = "d7_node_materiau_i18n",
|
||||
* source_module = "entity_translation"
|
||||
* )
|
||||
*/
|
||||
class D7NodeMateriauI18n extends FieldableEntity {
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function query() {
|
||||
$query = $this->select('entity_translation', 'et')
|
||||
->fields('et', [
|
||||
'entity_id',
|
||||
'revision_id',
|
||||
'language',
|
||||
'source',
|
||||
'uid',
|
||||
'status',
|
||||
'created',
|
||||
'changed',
|
||||
])
|
||||
->fields('n', [
|
||||
'nid',
|
||||
'title',
|
||||
'type',
|
||||
'promote',
|
||||
'sticky',
|
||||
])
|
||||
->fields('nr', [
|
||||
'log',
|
||||
'timestamp',
|
||||
])
|
||||
->condition('et.entity_type', 'node')
|
||||
->condition('et.source', '', '<>');
|
||||
|
||||
$query->addField('nr', 'uid', 'revision_uid');
|
||||
|
||||
$query->innerJoin('node', 'n', 'n.nid = et.entity_id');
|
||||
$query->innerJoin('node_revision', 'nr', 'nr.vid = et.revision_id');
|
||||
|
||||
if (isset($this->configuration['node_type'])) {
|
||||
$query->condition('n.type', $this->configuration['node_type']);
|
||||
}
|
||||
|
||||
return $query;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function prepareRow(Row $row) {
|
||||
$nid = $row->getSourceProperty('entity_id');
|
||||
$vid = $row->getSourceProperty('revision_id');
|
||||
$type = $row->getSourceProperty('type');
|
||||
$language = $row->getSourceProperty('language');
|
||||
$title = $row->getSourceProperty('title');
|
||||
// drush_print('-- '.$nid."\t".$title."\t".$language);
|
||||
|
||||
// Get Field API field values.
|
||||
foreach ($this->getFields('node', $type) as $field_name => $field) {
|
||||
// Ensure we're using the right language if the entity is translatable.
|
||||
$field_language = $field['translatable'] ? $language : NULL;
|
||||
$row->setSourceProperty($field_name, $this->getFieldValues('node', $field_name, $nid, $vid, $field_language));
|
||||
}
|
||||
|
||||
// If the node title was replaced by a real field using the Drupal 7 Title
|
||||
// module, use the field value instead of the node title.
|
||||
if ($this->moduleExists('title')) {
|
||||
$title_field = $row->getSourceProperty('title_field');
|
||||
if (isset($title_field[0]['value'])) {
|
||||
$row->setSourceProperty('title', $title_field[0]['value']);
|
||||
}
|
||||
}
|
||||
|
||||
return parent::prepareRow($row);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function fields() {
|
||||
return [
|
||||
'entity_id' => $this->t('Entity ID'),
|
||||
'revision_id' => $this->t('Revision ID'),
|
||||
'language' => $this->t('Node translation language'),
|
||||
'source' => $this->t('Node translation source language'),
|
||||
'uid' => $this->t('Node translation authored by (uid)'),
|
||||
'status' => $this->t('Published'),
|
||||
'created' => $this->t('Created timestamp'),
|
||||
'changed' => $this->t('Modified timestamp'),
|
||||
'title' => $this->t('Node title'),
|
||||
'type' => $this->t('Node type'),
|
||||
'promote' => $this->t('Promoted to front page'),
|
||||
'sticky' => $this->t('Sticky at top of lists'),
|
||||
'log' => $this->t('Revision log'),
|
||||
'timestamp' => $this->t('The timestamp the latest revision of this node was created.'),
|
||||
'revision_uid' => $this->t('Revision authored by (uid)'),
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getIds() {
|
||||
return [
|
||||
'entity_id' => [
|
||||
'type' => 'integer',
|
||||
'alias' => 'et',
|
||||
],
|
||||
'language' => [
|
||||
'type' => 'string',
|
||||
'alias' => 'et',
|
||||
],
|
||||
];
|
||||
}
|
||||
|
||||
}
|
@@ -0,0 +1,228 @@
|
||||
<?php
|
||||
|
||||
namespace Drupal\materio_migrate\Plugin\migrate\source;
|
||||
|
||||
use Drupal\migrate\Row;
|
||||
use Drupal\migrate_drupal\Plugin\migrate\source\d7\FieldableEntity;
|
||||
use Symfony\Component\DependencyInjection\ContainerInterface;
|
||||
use Drupal\Core\Plugin\ContainerFactoryPluginInterface;
|
||||
use Drupal\migrate\Plugin\MigrationInterface;
|
||||
use Drupal\Core\State\StateInterface;
|
||||
use Drupal\Core\Entity\EntityManagerInterface;
|
||||
use Drupal\Core\Locale\CountryManagerInterface;
|
||||
use libphonenumber\PhoneNumber;
|
||||
use libphonenumber\PhoneNumberUtil;
|
||||
use libphonenumber\PhoneNumberFormat;
|
||||
|
||||
/**
|
||||
* Taxonomy term source from database.
|
||||
*
|
||||
* @MigrateSource(
|
||||
* id = "d7_taxonomy_term_company",
|
||||
* source_module = "taxonomy"
|
||||
* )
|
||||
*/
|
||||
class D7TaxonomyTermCompany extends FieldableEntity implements ContainerFactoryPluginInterface{
|
||||
|
||||
/**
|
||||
* Phone Number util.
|
||||
*
|
||||
* @var \libphonenumber\PhoneNumberUtil
|
||||
*/
|
||||
public $phoneUtils;
|
||||
|
||||
/**
|
||||
* Country Manager service.
|
||||
*
|
||||
* @var \Drupal\Core\Locale\CountryManagerInterface
|
||||
*/
|
||||
public $countryManager;
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function __construct(array $configuration, $plugin_id, $plugin_definition, MigrationInterface $migration, StateInterface $state, EntityManagerInterface $entity_manager, CountryManagerInterface $country_manager) {
|
||||
parent::__construct($configuration, $plugin_id, $plugin_definition, $migration, $state, $entity_manager);
|
||||
$this->phoneUtils = PhoneNumberUtil::getInstance();
|
||||
$this->countryManager = $country_manager;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public static function create(ContainerInterface $container, array $configuration, $plugin_id, $plugin_definition, MigrationInterface $migration = NULL) {
|
||||
return new static(
|
||||
$configuration,
|
||||
$plugin_id,
|
||||
$plugin_definition,
|
||||
$migration,
|
||||
$container->get('state'),
|
||||
$container->get('entity.manager'),
|
||||
$container->get('country_manager')
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function query() {
|
||||
$query = $this->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."),
|
||||
'revision_id' => $this->t('Revision ID'),
|
||||
'language' => $this->t('Term translation language'),
|
||||
'source' => $this->t('Term translation source language'),
|
||||
'public_phone' => $this->t('Public phone converted to new format (with libphonenumber)')
|
||||
];
|
||||
return $fields;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function prepareRow(Row $row) {
|
||||
$language = $row->getSourceProperty('language');
|
||||
$tid = $row->getSourceProperty('tid');
|
||||
// drush_print('-- '.$language."\t".$tid."\t".$row->getSourceProperty('name'));
|
||||
|
||||
// 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) {
|
||||
// Ensure we're using the right language if the entity is translatable.
|
||||
$field_language = $field['translatable'] ? $language : NULL;
|
||||
$row->setSourceProperty($field_name, $this->getFieldValues('taxonomy_term', $field_name, $tid, $revid, $field_language));
|
||||
}
|
||||
|
||||
// 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);
|
||||
|
||||
// If the node title was replaced by a real field using the Drupal 7 Title
|
||||
// module, use the field value instead of the node title.
|
||||
if ($this->moduleExists('title')) {
|
||||
$name_field = $row->getSourceProperty('name_field');
|
||||
if (isset($name_field[0]['value'])) {
|
||||
$row->setSourceProperty('name', $name_field[0]['value']);
|
||||
}
|
||||
}
|
||||
|
||||
// get the tode nid
|
||||
$tode_nid = $this->select('field_data_field_tode_company', 'tode')
|
||||
->condition('entity_type', 'node')
|
||||
->condition('field_tode_company_tid', $tid)
|
||||
->fields('tode', ['entity_id'])
|
||||
->execute()->fetchField();
|
||||
// drush_print('tode_nid: '.$tode_nid);
|
||||
|
||||
// drush_print('tode_nid: ');
|
||||
// print_r($tode_nid);
|
||||
// drush_print(' ');
|
||||
if($tode_nid){
|
||||
// get the tode fields
|
||||
foreach ($this->getFields('node', 'company') as $field_name => $field) {
|
||||
// Ensure we're using the right language if the entity is translatable.
|
||||
$field_language = $field['translatable'] ? $language : NULL;
|
||||
$field_values = $this->getFieldValues('node', $field_name, $tode_nid, null, $field_language);
|
||||
|
||||
$row->setSourceProperty($field_name, $field_values);
|
||||
}
|
||||
|
||||
// make sure that field_website url is absolute
|
||||
$field_website = $row->getSourceProperty('field_website');
|
||||
if(isset($field_website[0]['url'])){
|
||||
$url = $field_website[0]['url'];
|
||||
if(!strpos($url, 'http://')){
|
||||
$field_website[0]['url'] = 'http://'.$url;
|
||||
$row->setSourceProperty('field_website', $field_website);
|
||||
}
|
||||
}
|
||||
|
||||
// convert phone field with libphonenumber
|
||||
$field_phone = $row->getSourceProperty('field_public_phone');
|
||||
if(isset($field_phone[0]['number']) && !empty($field_phone[0]['number'])){
|
||||
$national_number = $field_phone[0]['number'];
|
||||
$region = strtoupper($field_phone[0]['country_codes']);
|
||||
// isValidRegionCode($regionCode)
|
||||
if($this->phoneUtils->isPossibleNumber($national_number, $region)){
|
||||
$number = $this->phoneUtils->parse($national_number, $region);
|
||||
$row->setSourceProperty('public_phone', $this->phoneUtils->format($number, PhoneNumberFormat::E164));
|
||||
}else{
|
||||
// add bad phone number to memo field
|
||||
$memo .= "#migration : invalid phone number: ".$national_number.' region: '.$region."\n";
|
||||
drush_print('WARNING: phone number invalide; number: '.$national_number.' region: '.$region);
|
||||
}
|
||||
}
|
||||
|
||||
// TODO: attachment files
|
||||
// no needs as there is no attachment field used for companies
|
||||
|
||||
// workflow
|
||||
$query = $this->select('workflow_node', 'wn');
|
||||
$query->fields('wn', ['sid']);
|
||||
$query->condition('wn.nid', $tode_nid);
|
||||
$results = $query->execute()->fetchField();
|
||||
if(!$results){
|
||||
$results = 2;
|
||||
// add bad workflow to memo field
|
||||
$memo .= "#migration : invalid workflow\n";
|
||||
drush_print('WARNING: no workflow');
|
||||
}
|
||||
$row->setSourceProperty('workflow', $results);
|
||||
|
||||
}else{
|
||||
// if no tode set workflow to hidden
|
||||
$row->setSourceProperty('workflow', 2);
|
||||
$memo .= "#migration : missing data from tode\n";
|
||||
drush_print('WARNING: no tode');
|
||||
}
|
||||
// record migration errors in field_memo
|
||||
if(isset($memo)){
|
||||
$field_memo = $row->getSourceProperty('field_memo');
|
||||
$field_memo[0]['value'] .= "\n".$memo;
|
||||
$row->setSourceProperty('field_memo', $field_memo);
|
||||
}
|
||||
|
||||
return parent::prepareRow($row);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getIds() {
|
||||
$ids['tid']['type'] = 'integer';
|
||||
return $ids;
|
||||
}
|
||||
|
||||
}
|
@@ -0,0 +1,209 @@
|
||||
<?php
|
||||
|
||||
namespace Drupal\materio_migrate\Plugin\migrate\source;
|
||||
|
||||
use Drupal\migrate\Row;
|
||||
use Drupal\migrate_drupal\Plugin\migrate\source\d7\FieldableEntity;
|
||||
use Symfony\Component\DependencyInjection\ContainerInterface;
|
||||
use Drupal\Core\Plugin\ContainerFactoryPluginInterface;
|
||||
use Drupal\migrate\Plugin\MigrationInterface;
|
||||
use Drupal\Core\State\StateInterface;
|
||||
use Drupal\Core\Entity\EntityManagerInterface;
|
||||
use Drupal\Core\Locale\CountryManagerInterface;
|
||||
use libphonenumber\PhoneNumber;
|
||||
use libphonenumber\PhoneNumberUtil;
|
||||
use libphonenumber\PhoneNumberFormat;
|
||||
|
||||
/**
|
||||
* Taxonomy term source from database.
|
||||
*
|
||||
* @MigrateSource(
|
||||
* id = "d7_taxonomy_term_showroom",
|
||||
* source_module = "taxonomy"
|
||||
* )
|
||||
*/
|
||||
class D7TaxonomyTermShowroom extends FieldableEntity {
|
||||
|
||||
/**
|
||||
* Phone Number util.
|
||||
*
|
||||
* @var \libphonenumber\PhoneNumberUtil
|
||||
*/
|
||||
public $phoneUtils;
|
||||
|
||||
/**
|
||||
* Country Manager service.
|
||||
*
|
||||
* @var \Drupal\Core\Locale\CountryManagerInterface
|
||||
*/
|
||||
public $countryManager;
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function __construct(array $configuration, $plugin_id, $plugin_definition, MigrationInterface $migration, StateInterface $state, EntityManagerInterface $entity_manager, CountryManagerInterface $country_manager) {
|
||||
parent::__construct($configuration, $plugin_id, $plugin_definition, $migration, $state, $entity_manager);
|
||||
$this->phoneUtils = PhoneNumberUtil::getInstance();
|
||||
$this->countryManager = $country_manager;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public static function create(ContainerInterface $container, array $configuration, $plugin_id, $plugin_definition, MigrationInterface $migration = NULL) {
|
||||
return new static(
|
||||
$configuration,
|
||||
$plugin_id,
|
||||
$plugin_definition,
|
||||
$migration,
|
||||
$container->get('state'),
|
||||
$container->get('entity.manager'),
|
||||
$container->get('country_manager')
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function query() {
|
||||
$query = $this->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."),
|
||||
];
|
||||
return $fields;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function prepareRow(Row $row) {
|
||||
$language = $row->getSourceProperty('language');
|
||||
$tid = $row->getSourceProperty('tid');
|
||||
drush_print('-- '.$language."\t".$tid."\t".$row->getSourceProperty('name'));
|
||||
|
||||
// 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) {
|
||||
// Ensure we're using the right language if the entity is translatable.
|
||||
$field_language = $field['translatable'] ? $language : NULL;
|
||||
$row->setSourceProperty($field_name, $this->getFieldValues('taxonomy_term', $field_name, $tid, $revid, $field_language));
|
||||
}
|
||||
|
||||
// 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);
|
||||
// print_r($parents);
|
||||
|
||||
// If the node title was replaced by a real field using the Drupal 7 Title
|
||||
// module, use the field value instead of the node title.
|
||||
if ($this->moduleExists('title')) {
|
||||
$name_field = $row->getSourceProperty('name_field');
|
||||
if (isset($name_field[0]['value'])) {
|
||||
$row->setSourceProperty('name', $name_field[0]['value']);
|
||||
}
|
||||
}
|
||||
|
||||
// get the tode nid
|
||||
$tode_nid = $this->select('field_data_field_tode_showroom', 'tode')
|
||||
->condition('entity_type', 'node')
|
||||
->condition('field_tode_showroom_tid', $tid)
|
||||
->fields('tode', ['entity_id'])
|
||||
->execute()->fetchField();
|
||||
// drush_print('tode_nid: '.$tode_nid);
|
||||
|
||||
// drush_print('tode_nid: ');
|
||||
// print_r($tode_nid);
|
||||
// drush_print(' ');
|
||||
if($tode_nid){
|
||||
// get the tode fields
|
||||
foreach ($this->getFields('node', 'company') as $field_name => $field) {
|
||||
// Ensure we're using the right language if the entity is translatable.
|
||||
$field_language = $field['translatable'] ? $language : NULL;
|
||||
$field_values = $this->getFieldValues('node', $field_name, $tode_nid, null, $field_language);
|
||||
|
||||
$row->setSourceProperty($field_name, $field_values);
|
||||
}
|
||||
|
||||
// make sure that field_website url is absolute
|
||||
$field_website = $row->getSourceProperty('field_website');
|
||||
if(isset($field_website[0]['url'])){
|
||||
$url = $field_website[0]['url'];
|
||||
if(!strpos($url, 'http://')){
|
||||
$field_website[0]['url'] = 'http://'.$url;
|
||||
$row->setSourceProperty('field_website', $field_website);
|
||||
}
|
||||
}
|
||||
|
||||
// convert phone field with libphonenumber
|
||||
$field_phone = $row->getSourceProperty('field_public_phone');
|
||||
if(isset($field_phone[0]['number']) && !empty($field_phone[0]['number'])){
|
||||
$national_number = $field_phone[0]['number'];
|
||||
$region = strtoupper($field_phone[0]['country_codes']);
|
||||
// isValidRegionCode($regionCode)
|
||||
if($this->phoneUtils->isPossibleNumber($national_number, $region)){
|
||||
$number = $this->phoneUtils->parse($national_number, $region);
|
||||
$row->setSourceProperty('public_phone', $this->phoneUtils->format($number, PhoneNumberFormat::E164));
|
||||
}else{
|
||||
// add bad phone number to memo field
|
||||
$memo .= "#migration : invalid phone number: ".$national_number.' region: '.$region."\n";
|
||||
drush_print('WARNING: phone number invalide; number: '.$national_number.' region: '.$region);
|
||||
}
|
||||
}
|
||||
|
||||
}else{
|
||||
// if no tode set workflow to hidden
|
||||
$memo .= "#migration : missing data from tode\n";
|
||||
drush_print('WARNING: no tode');
|
||||
}
|
||||
// record migration errors in field_memo
|
||||
if(isset($memo)){
|
||||
$field_memo = $row->getSourceProperty('field_memo');
|
||||
$field_memo[0]['value'] .= "\n".$memo;
|
||||
$row->setSourceProperty('field_memo', $field_memo);
|
||||
}
|
||||
|
||||
|
||||
return parent::prepareRow($row);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getIds() {
|
||||
$ids['tid']['type'] = 'integer';
|
||||
return $ids;
|
||||
}
|
||||
|
||||
}
|
@@ -0,0 +1,111 @@
|
||||
<?php
|
||||
|
||||
namespace Drupal\materio_migrate\Plugin\migrate\source;
|
||||
|
||||
use Drupal\migrate\Row;
|
||||
use Drupal\migrate_drupal\Plugin\migrate\source\d7\FieldableEntity;
|
||||
|
||||
/**
|
||||
* Taxonomy term source from database.
|
||||
*
|
||||
* @MigrateSource(
|
||||
* id = "d7_taxonomy_term_tags",
|
||||
* source_module = "taxonomy"
|
||||
* )
|
||||
*/
|
||||
class D7TaxonomyTermTags extends FieldableEntity {
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function query() {
|
||||
$query = $this->select('taxonomy_term_data', 'td')
|
||||
->fields('td')
|
||||
->condition('et.entity_type', 'taxonomy_term')
|
||||
->condition('et.source', '')
|
||||
->orderBy('tid');
|
||||
|
||||
$query->innerJoin('entity_translation', 'et', 'et.entity_id = td.tid');
|
||||
$query->fields('et');
|
||||
|
||||
$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) {
|
||||
// Ensure we're using the right language if the entity is translatable.
|
||||
$field_language = $field['translatable'] ? $language : NULL;
|
||||
$row->setSourceProperty($field_name, $this->getFieldValues('taxonomy_term', $field_name, $tid, $revid, $field_language));
|
||||
}
|
||||
|
||||
// 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);
|
||||
|
||||
// If the node title was replaced by a real field using the Drupal 7 Title
|
||||
// module, use the field value instead of the node title.
|
||||
if ($this->moduleExists('title')) {
|
||||
$name_field = $row->getSourceProperty('name_field');
|
||||
if (isset($name_field[0]['value'])) {
|
||||
$row->setSourceProperty('name', $name_field[0]['value']);
|
||||
}
|
||||
}
|
||||
|
||||
return parent::prepareRow($row);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getIds() {
|
||||
$ids['tid']['type'] = 'integer';
|
||||
return $ids;
|
||||
}
|
||||
|
||||
}
|
@@ -0,0 +1,100 @@
|
||||
<?php
|
||||
|
||||
namespace Drupal\materio_migrate\Plugin\migrate\source;
|
||||
|
||||
use Drupal\migrate\Row;
|
||||
use Drupal\migrate_drupal\Plugin\migrate\source\d7\FieldableEntity;
|
||||
|
||||
/**
|
||||
* Taxonomy term source from database.
|
||||
*
|
||||
* @MigrateSource(
|
||||
* id = "d7_taxonomy_term_tags_i18n",
|
||||
* source_module = "taxonomy"
|
||||
* )
|
||||
*/
|
||||
class D7TaxonomyTermTagsI18n extends FieldableEntity {
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function query() {
|
||||
$query = $this->select('taxonomy_term_data', 'td')
|
||||
->fields('td')
|
||||
->condition('et.entity_type', 'taxonomy_term')
|
||||
->condition('et.source', '', '<>')
|
||||
->orderBy('tid');
|
||||
|
||||
$query->innerJoin('entity_translation', 'et', 'et.entity_id = td.tid');
|
||||
$query->fields('et');
|
||||
$query->leftJoin('taxonomy_vocabulary', 'tv', 'tv.vid = td.vid');
|
||||
$query->fields('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.'),
|
||||
'revision_id' => $this->t('Revision ID'),
|
||||
'language' => $this->t('Term translation language'),
|
||||
'source' => $this->t('Term translation source language'),
|
||||
'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."),
|
||||
];
|
||||
return $fields;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function prepareRow(Row $row) {
|
||||
$language = $row->getSourceProperty('language');
|
||||
$tid = $row->getSourceProperty('tid');
|
||||
|
||||
drush_print('-- '. $language ."\t".$tid."\t".$row->getSourceProperty('name'));
|
||||
|
||||
// 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) {
|
||||
// Ensure we're using the right language if the entity is translatable.
|
||||
$field_language = $field['translatable'] ? $language : NULL;
|
||||
$row->setSourceProperty($field_name, $this->getFieldValues('taxonomy_term', $field_name, $tid, $revid, $field_language));
|
||||
}
|
||||
|
||||
// If the node title was replaced by a real field using the Drupal 7 Title
|
||||
// module, use the field value instead of the node title.
|
||||
if ($this->moduleExists('title')) {
|
||||
$name_field = $row->getSourceProperty('name_field');
|
||||
if (isset($name_field[0]['value'])) {
|
||||
$row->setSourceProperty('name', $name_field[0]['value']);
|
||||
}
|
||||
}
|
||||
|
||||
return parent::prepareRow($row);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getIds() {
|
||||
$ids['tid']['type'] = 'integer';
|
||||
return $ids;
|
||||
}
|
||||
|
||||
}
|
@@ -0,0 +1,111 @@
|
||||
<?php
|
||||
|
||||
namespace Drupal\materio_migrate\Plugin\migrate\source;
|
||||
|
||||
use Drupal\migrate\Row;
|
||||
use Drupal\migrate_drupal\Plugin\migrate\source\d7\FieldableEntity;
|
||||
|
||||
/**
|
||||
* Taxonomy term source from database.
|
||||
*
|
||||
* @MigrateSource(
|
||||
* id = "d7_taxonomy_term_thesaurus",
|
||||
* source_module = "taxonomy"
|
||||
* )
|
||||
*/
|
||||
class D7TaxonomyTermThesaurus extends FieldableEntity {
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function query() {
|
||||
$query = $this->select('taxonomy_term_data', 'td')
|
||||
->fields('td')
|
||||
->condition('et.entity_type', 'taxonomy_term')
|
||||
->condition('et.source', '')
|
||||
->orderBy('tid');
|
||||
|
||||
$query->innerJoin('entity_translation', 'et', 'et.entity_id = td.tid');
|
||||
$query->fields('et');
|
||||
|
||||
$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) {
|
||||
// Ensure we're using the right language if the entity is translatable.
|
||||
$field_language = $field['translatable'] ? $language : NULL;
|
||||
$row->setSourceProperty($field_name, $this->getFieldValues('taxonomy_term', $field_name, $tid, $revid, $field_language));
|
||||
}
|
||||
|
||||
// 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);
|
||||
|
||||
// If the node title was replaced by a real field using the Drupal 7 Title
|
||||
// module, use the field value instead of the node title.
|
||||
if ($this->moduleExists('title')) {
|
||||
$name_field = $row->getSourceProperty('name_field');
|
||||
if (isset($name_field[0]['value'])) {
|
||||
$row->setSourceProperty('name', $name_field[0]['value']);
|
||||
}
|
||||
}
|
||||
|
||||
return parent::prepareRow($row);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getIds() {
|
||||
$ids['tid']['type'] = 'integer';
|
||||
return $ids;
|
||||
}
|
||||
|
||||
}
|
@@ -0,0 +1,100 @@
|
||||
<?php
|
||||
|
||||
namespace Drupal\materio_migrate\Plugin\migrate\source;
|
||||
|
||||
use Drupal\migrate\Row;
|
||||
use Drupal\migrate_drupal\Plugin\migrate\source\d7\FieldableEntity;
|
||||
|
||||
/**
|
||||
* Taxonomy term source from database.
|
||||
*
|
||||
* @MigrateSource(
|
||||
* id = "d7_taxonomy_term_thesaurus_i18n",
|
||||
* source_module = "taxonomy"
|
||||
* )
|
||||
*/
|
||||
class D7TaxonomyTermThesaurusI18n extends FieldableEntity {
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function query() {
|
||||
$query = $this->select('taxonomy_term_data', 'td')
|
||||
->fields('td')
|
||||
->condition('et.entity_type', 'taxonomy_term')
|
||||
->condition('et.source', '', '<>')
|
||||
->orderBy('tid');
|
||||
|
||||
$query->innerJoin('entity_translation', 'et', 'et.entity_id = td.tid');
|
||||
$query->fields('et');
|
||||
$query->leftJoin('taxonomy_vocabulary', 'tv', 'tv.vid = td.vid');
|
||||
$query->fields('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.'),
|
||||
'revision_id' => $this->t('Revision ID'),
|
||||
'language' => $this->t('Term translation language'),
|
||||
'source' => $this->t('Term translation source language'),
|
||||
'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."),
|
||||
];
|
||||
return $fields;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function prepareRow(Row $row) {
|
||||
$language = $row->getSourceProperty('language');
|
||||
$tid = $row->getSourceProperty('tid');
|
||||
|
||||
drush_print('-- '. $language ."\t".$tid."\t".$row->getSourceProperty('name'));
|
||||
|
||||
// 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) {
|
||||
// Ensure we're using the right language if the entity is translatable.
|
||||
$field_language = $field['translatable'] ? $language : NULL;
|
||||
$row->setSourceProperty($field_name, $this->getFieldValues('taxonomy_term', $field_name, $tid, $revid, $field_language));
|
||||
}
|
||||
|
||||
// If the node title was replaced by a real field using the Drupal 7 Title
|
||||
// module, use the field value instead of the node title.
|
||||
if ($this->moduleExists('title')) {
|
||||
$name_field = $row->getSourceProperty('name_field');
|
||||
if (isset($name_field[0]['value'])) {
|
||||
$row->setSourceProperty('name', $name_field[0]['value']);
|
||||
}
|
||||
}
|
||||
|
||||
return parent::prepareRow($row);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getIds() {
|
||||
$ids['tid']['type'] = 'integer';
|
||||
return $ids;
|
||||
}
|
||||
|
||||
}
|
Reference in New Issue
Block a user