public function FieldInstanceOptionTranslation::transform in Drupal 9
Same name in this branch
- 9 core/modules/field/src/Plugin/migrate/process/d6/FieldInstanceOptionTranslation.php \Drupal\field\Plugin\migrate\process\d6\FieldInstanceOptionTranslation::transform()
- 9 core/modules/field/src/Plugin/migrate/process/d7/FieldInstanceOptionTranslation.php \Drupal\field\Plugin\migrate\process\d7\FieldInstanceOptionTranslation::transform()
Same name and namespace in other branches
- 8 core/modules/field/src/Plugin/migrate/process/d7/FieldInstanceOptionTranslation.php \Drupal\field\Plugin\migrate\process\d7\FieldInstanceOptionTranslation::transform()
Performs the associated process.
Parameters
mixed $value: The value to be transformed.
\Drupal\migrate\MigrateExecutableInterface $migrate_executable: The migration in which this process is being executed.
\Drupal\migrate\Row $row: The row from the source to process. Normally, just transforming the value is adequate but very rarely you might need to change two columns at the same time or something like that.
string $destination_property: The destination property currently worked on. This is only used together with the $row above.
Return value
string|array The newly transformed value.
Overrides ProcessPluginBase::transform
File
- core/
modules/ field/ src/ Plugin/ migrate/ process/ d7/ FieldInstanceOptionTranslation.php, line 22
Class
- FieldInstanceOptionTranslation
- Determines the settings property and translation for boolean fields.
Namespace
Drupal\field\Plugin\migrate\process\d7Code
public function transform($value, MigrateExecutableInterface $migrate_executable, Row $row, $destination_property) {
list($type, $data) = $value;
$data = unserialize($data);
$property = $row
->getSourceProperty('property');
$option_key = $property == 0 ? 'off_label' : 'on_label';
$translation = '';
if (isset($data['settings']['allowed_values'])) {
$allowed_values = $data['settings']['allowed_values'];
switch ($type) {
case 'boolean':
if (isset($allowed_values[$property])) {
$translation = $row
->getSourceProperty('translation');
break;
}
break;
default:
}
}
return [
'settings.' . $option_key,
$translation,
];
}