Commit 5b3fdce4 authored by catch's avatar catch

Issue #2887142 by maxocub, phenaproxima, Jo Fitzgerald, Adita, heddn,...

Issue #2887142 by maxocub, phenaproxima, Jo Fitzgerald, Adita, heddn, andypost: NodeType source plugin should include comment information
parent e8875156
...@@ -16,10 +16,15 @@ process: ...@@ -16,10 +16,15 @@ process:
source: pid source: pid
entity_id: nid entity_id: nid
entity_type: 'constants/entity_type' entity_type: 'constants/entity_type'
# field_name & comment_type is calculated in comment_type:
# \Drupal\migrate_drupal\Plugin\migrate\source\d6\Comment::prepareRow() -
field_name: field_name plugin: migration_lookup
comment_type: comment_type source: type
migration: d6_comment_type
-
plugin: skip_on_empty
method: row
field_name: '@comment_type'
subject: subject subject: subject
uid: uid uid: uid
name: name name: name
......
...@@ -3,10 +3,9 @@ label: Comment display configuration ...@@ -3,10 +3,9 @@ label: Comment display configuration
migration_tags: migration_tags:
- Drupal 6 - Drupal 6
source: source:
plugin: d6_comment_variable plugin: d6_node_type
constants: constants:
entity_type: node entity_type: node
field_name: comment
view_mode: default view_mode: default
options: options:
label: hidden label: hidden
...@@ -14,10 +13,17 @@ source: ...@@ -14,10 +13,17 @@ source:
weight: 20 weight: 20
process: process:
entity_type: 'constants/entity_type' entity_type: 'constants/entity_type'
field_name: 'constants/field_name' field_name:
-
plugin: migration_lookup
source: type
migration: d6_comment_type
-
plugin: skip_on_empty
method: row
view_mode: 'constants/view_mode' view_mode: 'constants/view_mode'
options: 'constants/options' options: 'constants/options'
bundle: node_type bundle: type
destination: destination:
plugin: component_entity_display plugin: component_entity_display
migration_dependencies: migration_dependencies:
......
...@@ -3,20 +3,26 @@ label: Comment field form display configuration ...@@ -3,20 +3,26 @@ label: Comment field form display configuration
migration_tags: migration_tags:
- Drupal 6 - Drupal 6
source: source:
plugin: d6_comment_variable plugin: d6_node_type
constants: constants:
entity_type: node entity_type: node
field_name: comment
form_mode: default form_mode: default
options: options:
type: comment_default type: comment_default
weight: 20 weight: 20
process: process:
entity_type: 'constants/entity_type' entity_type: 'constants/entity_type'
field_name: 'constants/field_name' field_name:
-
plugin: migration_lookup
source: type
migration: d6_comment_type
-
plugin: skip_on_empty
method: row
form_mode: 'constants/form_mode' form_mode: 'constants/form_mode'
options: 'constants/options' options: 'constants/options'
bundle: node_type bundle: type
destination: destination:
plugin: component_entity_form_display plugin: component_entity_form_display
migration_dependencies: migration_dependencies:
......
...@@ -3,7 +3,7 @@ label: Comment subject form display configuration ...@@ -3,7 +3,7 @@ label: Comment subject form display configuration
migration_tags: migration_tags:
- Drupal 6 - Drupal 6
source: source:
plugin: d6_comment_variable_per_comment_type plugin: d6_node_type
constants: constants:
entity_type: comment entity_type: comment
field_name: subject field_name: subject
...@@ -16,14 +16,23 @@ process: ...@@ -16,14 +16,23 @@ process:
field_name: 'constants/field_name' field_name: 'constants/field_name'
form_mode: 'constants/form_mode' form_mode: 'constants/form_mode'
options: 'constants/options' options: 'constants/options'
bundle:
-
plugin: migration_lookup
source: type
migration: d6_comment_type
-
plugin: skip_on_empty
method: row
hidden: hidden:
plugin: static_map plugin: static_map
source: comment_type source: comment_subject_field
default_value: false
map: map:
comment_no_subject: true # Hide subject field # If comment_subject_field = FALSE, then hidden = TRUE.
comment: false 0: true
bundle: comment_type # If comment_subject_field = TRUE, then hidden = FALSE.
1: false
default_value: false
destination: destination:
plugin: component_entity_form_display plugin: component_entity_form_display
migration_dependencies: migration_dependencies:
......
...@@ -3,20 +3,24 @@ label: Comment field configuration ...@@ -3,20 +3,24 @@ label: Comment field configuration
migration_tags: migration_tags:
- Drupal 6 - Drupal 6
source: source:
plugin: d6_comment_variable_per_comment_type plugin: d6_node_type
constants: constants:
entity_type: node entity_type: node
type: comment type: comment
process: process:
entity_type: 'constants/entity_type' entity_type: 'constants/entity_type'
field_name: comment_type field_name:
-
plugin: migration_lookup
source: type
migration: d6_comment_type
-
plugin: skip_on_empty
method: row
type: 'constants/type' type: 'constants/type'
'settings/comment_type': comment_type 'settings/comment_type': '@field_name'
destination: destination:
plugin: entity:field_storage_config plugin: entity:field_storage_config
dependencies:
module:
- comment
migration_dependencies: migration_dependencies:
required: required:
- d6_comment_type - d6_comment_type
...@@ -3,7 +3,7 @@ label: Comment field instance configuration ...@@ -3,7 +3,7 @@ label: Comment field instance configuration
migration_tags: migration_tags:
- Drupal 6 - Drupal 6
source: source:
plugin: d6_comment_variable plugin: d6_node_type
constants: constants:
entity_type: node entity_type: node
label: Comments label: Comments
...@@ -13,13 +13,24 @@ process: ...@@ -13,13 +13,24 @@ process:
label: 'constants/label' label: 'constants/label'
required: 'constants/required' required: 'constants/required'
field_name: field_name:
-
plugin: migration_lookup
source: type
migration: d6_comment_type
-
plugin: skip_on_empty
method: row
bundle: type
'default_value/0/status':
# We're using static_map instead of default_value otherwise if the source
# is 0, the default value of 1 would be used.
plugin: static_map plugin: static_map
source: comment_subject_field source: comment
default_value: comment
map: map:
0: comment_no_subject 0: 0
bundle: node_type 1: 1
'default_value/0/status': comment 2: 2
default_value: 2
'settings/default_mode': 'settings/default_mode':
plugin: static_map plugin: static_map
source: comment_default_mode source: comment_default_mode
...@@ -32,13 +43,31 @@ process: ...@@ -32,13 +43,31 @@ process:
3: 1 3: 1
# COMMENT_MODE_THREADED_EXPANDED --> COMMENT_MODE_THREADED # COMMENT_MODE_THREADED_EXPANDED --> COMMENT_MODE_THREADED
4: 1 4: 1
'settings/per_page': comment_default_per_page default_value: 1
'settings/anonymous': comment_anonymous 'settings/per_page':
'settings/form_location': comment_form_location plugin: default_value
'settings/preview': comment_preview source: comment_default_per_page
default_value: 50
'settings/anonymous':
plugin: default_value
source: comment_anonymous
default_value: 0
'settings/form_location':
plugin: default_value
source: comment_form_location
default_value: 0
'settings/preview':
# We're using static_map instead of default_value otherwise if the source
# is 0, the default value of 1 would be used.
plugin: static_map
source: comment_preview
map:
0: 0
1: 1
default_value: 1
destination: destination:
plugin: entity:field_config plugin: entity:field_config
migration_dependencies: migration_dependencies:
required: required:
- d6_comment_field
- d6_node_type - d6_node_type
- d6_comment_field
...@@ -3,13 +3,31 @@ label: Comment type ...@@ -3,13 +3,31 @@ label: Comment type
migration_tags: migration_tags:
- Drupal 6 - Drupal 6
source: source:
plugin: d6_comment_variable_per_comment_type plugin: d6_node_type
constants: constants:
entity_type: node entity_type: node
id_prefix: 'comment_node_'
label_suffix: 'comment'
process: process:
target_entity_type_id: 'constants/entity_type' target_entity_type_id: 'constants/entity_type'
id: comment_type id:
label: label -
description: description plugin: concat
source:
- 'constants/id_prefix'
- type
-
plugin: static_map
bypass: true
# The Forum module provides its own comment type (comment_forum), which we
# want to reuse if it exists.
map:
comment_node_forum: comment_forum
label:
plugin: concat
source:
- name
- 'constants/label_suffix'
delimiter: ' '
destination: destination:
plugin: entity:comment_type plugin: entity:comment_type
...@@ -19,7 +19,7 @@ process: ...@@ -19,7 +19,7 @@ process:
comment_type: comment_type:
- -
plugin: migration_lookup plugin: migration_lookup
source: comment_type source: node_type
migration: d7_comment_type migration: d7_comment_type
- -
plugin: skip_on_empty plugin: skip_on_empty
......
...@@ -3,7 +3,7 @@ label: Comment display configuration ...@@ -3,7 +3,7 @@ label: Comment display configuration
migration_tags: migration_tags:
- Drupal 7 - Drupal 7
source: source:
plugin: d7_comment_type plugin: d7_node_type
constants: constants:
entity_type: node entity_type: node
view_mode: default view_mode: default
...@@ -16,14 +16,14 @@ process: ...@@ -16,14 +16,14 @@ process:
field_name: field_name:
- -
plugin: migration_lookup plugin: migration_lookup
source: bundle source: type
migration: d7_comment_type migration: d7_comment_type
- -
plugin: skip_on_empty plugin: skip_on_empty
method: row method: row
view_mode: 'constants/view_mode' view_mode: 'constants/view_mode'
options: 'constants/options' options: 'constants/options'
bundle: node_type bundle: type
destination: destination:
plugin: component_entity_display plugin: component_entity_display
migration_dependencies: migration_dependencies:
......
...@@ -3,20 +3,26 @@ label: Comment field form display configuration ...@@ -3,20 +3,26 @@ label: Comment field form display configuration
migration_tags: migration_tags:
- Drupal 7 - Drupal 7
source: source:
plugin: d7_comment_type plugin: d7_node_type
constants: constants:
entity_type: node entity_type: node
field_name: comment
form_mode: default form_mode: default
options: options:
type: comment_default type: comment_default
weight: 20 weight: 20
process: process:
entity_type: 'constants/entity_type' entity_type: 'constants/entity_type'
field_name: 'constants/field_name' field_name:
-
plugin: migration_lookup
source: type
migration: d7_comment_type
-
plugin: skip_on_empty
method: row
form_mode: 'constants/form_mode' form_mode: 'constants/form_mode'
options: 'constants/options' options: 'constants/options'
bundle: node_type bundle: type
destination: destination:
plugin: component_entity_form_display plugin: component_entity_form_display
migration_dependencies: migration_dependencies:
......
...@@ -3,7 +3,7 @@ label: Comment subject form display configuration ...@@ -3,7 +3,7 @@ label: Comment subject form display configuration
migration_tags: migration_tags:
- Drupal 7 - Drupal 7
source: source:
plugin: d7_comment_type plugin: d7_node_type
constants: constants:
entity_type: comment entity_type: comment
field_name: subject field_name: subject
...@@ -16,20 +16,23 @@ process: ...@@ -16,20 +16,23 @@ process:
field_name: 'constants/field_name' field_name: 'constants/field_name'
form_mode: 'constants/form_mode' form_mode: 'constants/form_mode'
options: 'constants/options' options: 'constants/options'
hidden:
plugin: static_map
source: subject
map:
0: true
1: false
bundle: bundle:
- -
plugin: migration_lookup plugin: migration_lookup
source: bundle source: type
migration: d7_comment_type migration: d7_comment_type
- -
plugin: skip_on_empty plugin: skip_on_empty
method: row method: row
hidden:
plugin: static_map
source: comment_subject_field
map:
# If comment_subject_field = FALSE, then hidden = TRUE.
0: true
# If comment_subject_field = TRUE, then hidden = FALSE.
1: false
default_value: false
destination: destination:
plugin: component_entity_form_display plugin: component_entity_form_display
migration_dependencies: migration_dependencies:
......
...@@ -3,7 +3,7 @@ label: Comment field configuration ...@@ -3,7 +3,7 @@ label: Comment field configuration
migration_tags: migration_tags:
- Drupal 7 - Drupal 7
source: source:
plugin: d7_comment_type plugin: d7_node_type
constants: constants:
entity_type: node entity_type: node
type: comment type: comment
...@@ -12,7 +12,7 @@ process: ...@@ -12,7 +12,7 @@ process:
field_name: field_name:
- -
plugin: migration_lookup plugin: migration_lookup
source: bundle source: type
migration: d7_comment_type migration: d7_comment_type
- -
plugin: skip_on_empty plugin: skip_on_empty
......
...@@ -3,7 +3,7 @@ label: Comment field instance configuration ...@@ -3,7 +3,7 @@ label: Comment field instance configuration
migration_tags: migration_tags:
- Drupal 7 - Drupal 7
source: source:
plugin: d7_comment_type plugin: d7_node_type
constants: constants:
entity_type: node entity_type: node
label: Comments label: Comments
...@@ -15,20 +15,56 @@ process: ...@@ -15,20 +15,56 @@ process:
field_name: field_name:
- -
plugin: migration_lookup plugin: migration_lookup
source: bundle source: type
migration: d7_comment_type migration: d7_comment_type
- -
plugin: skip_on_empty plugin: skip_on_empty
method: row method: row
bundle: node_type bundle: type
'default_value/0/status': 'constants/required' 'default_value/0/status':
'settings/default_mode': default_mode # We're using static_map instead of default_value otherwise if the source
'settings/per_page': per_page # is 0, the default value of 1 would be used.
'settings/anonymous': anonymous plugin: static_map
'settings/form_location': form_location source: comment
'settings/preview': preview map:
0: 0
1: 1
2: 2
default_value: 2
'settings/default_mode':
# We're using static_map instead of default_value otherwise if the source
# is 0, the default value of 1 would be used.
plugin: static_map
source: comment_default_mode
map:
0: 0
1: 1
default_value: 1
'settings/per_page':
plugin: default_value
source: comment_default_per_page
default_value: 50
'settings/anonymous':
plugin: default_value
source: comment_anonymous
default_value: 0
'settings/form_location':
plugin: default_value
source: comment_form_location
default_value: 0
'settings/preview':
# We're using static_map instead of default_value otherwise if the source
# is 0, the default value of 1 would be used.
plugin: static_map
source: comment_preview
map:
0: 0
1: 1
2: 2
default_value: 1
destination: destination:
plugin: entity:field_config plugin: entity:field_config
migration_dependencies: migration_dependencies:
required: required:
- d7_node_type
- d7_comment_field - d7_comment_field
...@@ -3,22 +3,31 @@ label: Comment type ...@@ -3,22 +3,31 @@ label: Comment type
migration_tags: migration_tags:
- Drupal 7 - Drupal 7
source: source:
plugin: d7_comment_type plugin: d7_node_type
constants: constants:
entity_type: node entity_type: node
id_prefix: 'comment_node_'
label_suffix: 'comment'
process: process:
target_entity_type_id: 'constants/entity_type' target_entity_type_id: 'constants/entity_type'
id: id:
plugin: static_map -
source: bundle plugin: concat
bypass: true source:
# The Forum module provides its own comment type (comment_forum), which we - 'constants/id_prefix'
# want to reuse if it exists. - type
map: -
comment_node_forum: comment_forum plugin: static_map
label: label bypass: true
# The Forum module provides its own comment type (comment_forum), which we
# want to reuse if it exists.
map:
comment_node_forum: comment_forum
label:
plugin: concat
source:
- name
- 'constants/label_suffix'
delimiter: ' '
destination: destination:
plugin: entity:comment_type plugin: entity:comment_type
migration_dependencies:
required:
- d7_node_type
...@@ -34,6 +34,20 @@ public function query() { ...@@ -34,6 +34,20 @@ public function query() {
* {@inheritdoc} * {@inheritdoc}
*/ */
public function prepareRow(Row $row) { public function prepareRow(Row $row) {
return parent::prepareRow($this->prepareComment($row));
}
/**
* This is a backward compatibility layer for the deprecated migrate source
* plugins d6_comment_variable and d6_comment_variable_per_comment_type.
*
* @param \Drupal\migrate\Row $row
* The row from the source to process.
* @return \Drupal\migrate\Row
* The row object.
* @deprecated in Drupal 8.4.x, to be removed before Drupal 9.0.x.
*/
protected function prepareComment(Row $row) {
if ($this->variableGet('comment_subject_field_' . $row->getSourceProperty('type'), 1)) { if ($this->variableGet('comment_subject_field_' . $row->getSourceProperty('type'), 1)) {
// Comment subject visible. // Comment subject visible.
$row->setSourceProperty('field_name', 'comment'); $row->setSourceProperty('field_name', 'comment');
...@@ -43,10 +57,11 @@ public function prepareRow(Row $row) { ...@@ -43,10 +57,11 @@ public function prepareRow(Row $row) {
$row->setSourceProperty('field_name', 'comment_no_subject'); $row->setSourceProperty('field_name', 'comment_no_subject');
$row->setSourceProperty('comment_type', 'comment_no_subject'); $row->setSourceProperty('comment_type', 'comment_no_subject');
} }
// In D6, status=0 means published, while in D8 means the opposite. // In D6, status=0 means published, while in D8 means the opposite.
// See https://www.drupal.org/node/237636. // See https://www.drupal.org/node/237636.
$row->setSourceProperty('status', !$row->getSourceProperty('status')); $row->setSourceProperty('status', !$row->getSourceProperty('status'));
return parent::prepareRow($row);