Commit fbafc692 authored by catch's avatar catch

Issue #2726803 by hussainweb, jmuzz, Jo Fitzgerald: Field formatters with...

Issue #2726803 by hussainweb, jmuzz, Jo Fitzgerald: Field formatters with names different than their field type can not be migrated
parent 222fa031
......@@ -51,7 +51,7 @@ process:
-
plugin: static_map
bypass: true
source: type
source: formatter_type
map:
date_default: datetime_default
email_default: email_mailto
......
......@@ -24,8 +24,15 @@ protected function initializeIterator() {
$data = unserialize($field_instance['data']);
// We don't need to include the serialized data in the returned rows.
unset($field_instance['data']);
foreach ($data['display'] as $view_mode => $info) {
$rows[] = array_merge($field_instance, $info, array('view_mode' => $view_mode));
// Rename type to formatter_type in the info array.
$info['formatter_type'] = $info['type'];
unset($info['type']);
$rows[] = array_merge($field_instance, $info, [
'view_mode' => $view_mode,
]);
}
}
return new \ArrayIterator($rows);
......@@ -35,8 +42,11 @@ protected function initializeIterator() {
* {@inheritdoc}
*/
public function query() {
return $this->select('field_config_instance', 'fci')
->fields('fci', array('entity_type', 'bundle', 'field_name', 'data'));
$query = $this->select('field_config_instance', 'fci')
->fields('fci', ['entity_type', 'bundle', 'field_name', 'data'])
->fields('fc', ['type']);
$query->join('field_config', 'fc', 'fc.field_name = fci.field_name');
return $query;
}
/**
......@@ -49,7 +59,8 @@ public function fields() {
'field_name' => $this->t('Machine name of the field.'),
'view_mode' => $this->t('The original machine name of the view mode.'),
'label' => $this->t('The display label of the field.'),
'type' => $this->t('The formatter ID.'),
'type' => $this->t('The field ID.'),
'formatter_type' => $this->t('The formatter ID.'),
'settings' => $this->t('Array of formatter-specific settings.'),
'module' => $this->t('The module providing the formatter.'),
'weight' => $this->t('Display weight of the field.'),
......
......@@ -41,6 +41,24 @@ public function providerSource() {
],
];
$tests[0]['source_data']['field_config'] = [
[
'id' => '2',
'field_name' => 'body',
'type' => 'text_with_summary',
'module' => 'text',
'active' => '1',
'storage_type' => 'field_sql_storage',
'storage_module' => 'field_sql_storage',
'storage_active' => '1',
'locked' => '0',
'data' => 'a:7:{s:12:"entity_types";a:1:{i:0;s:4:"node";}s:7:"indexes";a:1:{s:6:"format";a:1:{i:0;s:6:"format";}}s:8:"settings";a:0:{}s:12:"translatable";i:0;s:12:"foreign keys";a:1:{s:6:"format";a:2:{s:5:"table";s:13:"filter_format";s:7:"columns";a:1:{s:6:"format";s:6:"format";}}}s:7:"storage";a:4:{s:4:"type";s:17:"field_sql_storage";s:8:"settings";a:0:{}s:6:"module";s:17:"field_sql_storage";s:6:"active";s:1:"1";}s:2:"id";s:2:"25";}',
'cardinality' => '1',
'translatable' => '0',
'deleted' => '0',
],
];
// The expected results.
$tests[0]['expected_data'] = [
[
......@@ -48,7 +66,8 @@ public function providerSource() {
'bundle' => 'page',
'field_name' => 'body',
'label' => 'hidden',
'type' => 'text_default',
'type' => 'text_with_summary',
'formatter_type' => 'text_default',
'settings' => [],
'module' => 'text',
'weight' => 0,
......@@ -59,7 +78,8 @@ public function providerSource() {
'bundle' => 'page',
'field_name' => 'body',
'label' => 'hidden',
'type' => 'text_summary_or_trimmed',
'type' => 'text_with_summary',
'formatter_type' => 'text_summary_or_trimmed',
'settings' => [
'trim_length' => 600,
],
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment