public function Paragraphs::defineValueProcessPipeline in Paragraphs 8
Apply any custom processing to the field bundle migrations.
Parameters
\Drupal\migrate\Plugin\MigrationInterface $migration: The migration entity.
string $field_name: The field name we're processing the value for.
array $data: The array of field data from FieldValues::fieldData().
Overrides FieldPluginBase::defineValueProcessPipeline
File
- src/
Plugin/ migrate/ field/ Paragraphs.php, line 26
Class
- Paragraphs
- Field Plugin for paragraphs migrations.
Namespace
Drupal\paragraphs\Plugin\migrate\fieldCode
public function defineValueProcessPipeline(MigrationInterface $migration, $field_name, $data) {
$process = [
'plugin' => 'sub_process',
'source' => $field_name,
'process' => [
'target_id' => [
[
'plugin' => 'paragraphs_lookup',
'tags' => 'Paragraphs Content',
'source' => 'value',
],
[
'plugin' => 'extract',
'index' => [
'id',
],
],
],
'target_revision_id' => [
[
'plugin' => 'paragraphs_lookup',
'tags' => [
'Paragraphs Revisions Content',
'Paragraphs Content',
],
'tag_ids' => [
'Paragraphs Revisions Content' => [
'revision_id',
],
'Paragraphs Content' => [
'value',
],
],
// D8.4 Does not like an empty source value, Even when using ids.
'source' => 'value',
],
[
'plugin' => 'extract',
'index' => [
'revision_id',
],
],
],
],
];
$migration
->setProcessOfProperty($field_name, $process);
// Add paragraphs migration as a dependency (if this is not a paragraph
// migration).
// @todo: This is a great example why we should consider derive paragraph
// migrations based on parent entity type (and bundle).
if (!in_array('Paragraphs Content', $migration
->getMigrationTags(), TRUE)) {
$dependencies = $migration
->getMigrationDependencies() + [
'required' => [],
];
$dependencies['required'] = array_unique(array_merge(array_values($dependencies['required']), [
'd7_paragraphs',
]));
$migration
->set('migration_dependencies', $dependencies);
if (strpos($migration
->getDestinationPlugin()
->getPluginId(), 'entity_revision:') === 0 || strpos($migration
->getDestinationPlugin()
->getPluginId(), 'entity_complete:') === 0) {
$dependencies['required'] = array_unique(array_merge(array_values($dependencies['required']), [
'd7_paragraphs_revisions',
]));
$migration
->set('migration_dependencies', $dependencies);
}
}
}