public function FarmMigrateGetLab::transform in farmOS 2.x
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
- modules/
core/ migrate/ src/ Plugin/ migrate/ process/ FarmMigrateGetLab.php, line 21
Class
- FarmMigrateGetLab
- Gets the testing lab from a soil/water test log.
Namespace
Drupal\farm_migrate\Plugin\migrate\processCode
public function transform($value, MigrateExecutableInterface $migrate_executable, Row $row, $destination_property) {
// First try to get a soil lab.
$lab = $row
->get('field_farm_soil_lab');
// If that failed, try to get a water lab.
if (empty($lab)) {
$lab = $row
->get('field_farm_water_lab');
}
// If a lab was found, return it.
$return = [];
if (!empty($lab)) {
$return[] = $lab;
}
return $return;
}