IngredientReference.php in Recipe 8.2
File
modules/ingredient/src/Plugin/migrate/field/IngredientReference.php
View source
<?php
namespace Drupal\ingredient\Plugin\migrate\field;
use Drupal\migrate\Plugin\MigrationInterface;
use Drupal\migrate_drupal\Plugin\migrate\field\FieldPluginBase;
class IngredientReference extends FieldPluginBase {
public function alterFieldInstanceMigration(MigrationInterface $migration) {
parent::alterFieldInstanceMigration($migration);
$process = [
'plugin' => 'get',
'source' => 'widget/settings/default_unit',
];
$migration
->mergeProcessOfProperty('settings/default_unit', $process);
}
public function getFieldWidgetMap() {
return [
'recipe_ingredient_autocomplete' => 'ingredient_autocomplete',
];
}
public function getFieldFormatterMap() {
return [
'recipe_ingredient_default' => 'ingredient_default',
];
}
public function alterFieldFormatterMigration(MigrationInterface $migration) {
parent::alterFieldFormatterMigration($migration);
$process = [
'plugin' => 'get',
'source' => 'formatter/settings/unit_abbreviation',
];
$migration
->mergeProcessOfProperty('options/settings/unit_display', $process);
}
public function defineValueProcessPipeline(MigrationInterface $migration, $field_name, $data) {
$process = [
'plugin' => 'sub_process',
'source' => $field_name,
'process' => [
'target_id' => [
'plugin' => 'migration_lookup',
'migration' => 'recipe1x_ingredient',
'source' => 'iid',
],
'quantity' => 'quantity',
'unit_key' => 'unit_key',
'note' => 'note',
],
];
$migration
->setProcessOfProperty($field_name, $process);
}
}