Commit 23fde8da authored by alexpott's avatar alexpott
Browse files

Issue #2528688 by phenaproxima: Create cckfield plugin for file fields

parent 5e87cfb2
......@@ -91,13 +91,6 @@ process:
spamspan: email_mailto
contact: email_mailto
plain: basic_string
filefield:
default: file_default
url_plain: file_url_plain
path_plain: file_url_plain
image_plain: image
image_nodelink: image
image_imagelink: image
fr_phone:
default: basic_string
be_phone:
......
......@@ -41,7 +41,6 @@ process:
email_textfield: email_default
date_select: datetime_default
date_text: datetime_default
filefield_widget: file_generic
imagefield_widget: image_image
phone_textfield: telephone_default
optionwidgets_onoff: boolean_checkbox
......
<?php
/**
* @file
* Contains \Drupal\migrate_drupal\Plugin\migrate\cckfield\FileField.
*/
namespace Drupal\migrate_drupal\Plugin\migrate\cckfield;
use Drupal\migrate\Entity\MigrationInterface;
/**
* @PluginID("filefield")
*/
class FileField extends CckFieldPluginBase {
/**
* {@inheritdoc}
*/
public function getFieldWidgetMap() {
return [
'filefield_widget' => 'file_generic',
];
}
/**
* {@inheritdoc}
*/
public function getFieldFormatterMap() {
return [
'default' => 'file_default',
'url_plain' => 'file_url_plain',
'path_plain' => 'file_url_plain',
'image_plain' => 'image',
'image_nodelink' => 'image',
'image_imagelink' => 'image',
];
}
/**
* {@inheritdoc}
*/
public function processCckFieldValues(MigrationInterface $migration, $field_name, $data) {
$process = [
'plugin' => 'd6_cck_file',
'source' => [
$field_name,
$field_name . '_list',
$field_name . '_data',
],
];
$migration->mergeProcessOfProperty($field_name, $process);
}
}
......@@ -88,9 +88,6 @@ public function loadMultiple(EntityStorageInterface $storage, array $sub_ids = N
if ($source_plugin instanceof CckFieldMigrateSourceInterface) {
foreach ($source_plugin->fieldData() as $field_name => $data) {
switch ($data['type']) {
case 'filefield':
$this->processFileField($field_name, $data, $migration);
break;
case 'text':
$this->processTextField($field_name, $data, $migration);
break;
......@@ -154,26 +151,4 @@ protected function processTextField($field_name, $field_data, MigrationInterface
$migration->mergeProcessOfProperty("$field_name/format", $process);
}
/**
* Manipulate file fields with any per field type processing.
*
* @param string $field_name
* The field we're processing.
* @param array $field_data
* The an array of field type data from the source.
* @param \Drupal\migrate\Entity\MigrationInterface $migration
* The migration entity.
*/
protected function processFileField($field_name, $field_data, MigrationInterface $migration) {
$process = [
'plugin' => 'd6_cck_file',
'source' => [
$field_name,
$field_name . '_list',
$field_name . '_data',
],
];
$migration->mergeProcessOfProperty($field_name, $process);
}
}
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