You are here

public function EntityLookup::transform in Migrate Plus 8.4

Same name and namespace in other branches
  1. 8.5 src/Plugin/migrate/process/EntityLookup.php \Drupal\migrate_plus\Plugin\migrate\process\EntityLookup::transform()
  2. 8.2 src/Plugin/migrate/process/EntityLookup.php \Drupal\migrate_plus\Plugin\migrate\process\EntityLookup::transform()
  3. 8.3 src/Plugin/migrate/process/EntityLookup.php \Drupal\migrate_plus\Plugin\migrate\process\EntityLookup::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

1 call to EntityLookup::transform()
EntityGenerate::transform in src/Plugin/migrate/process/EntityGenerate.php
Performs the associated process.
1 method overrides EntityLookup::transform()
EntityGenerate::transform in src/Plugin/migrate/process/EntityGenerate.php
Performs the associated process.

File

src/Plugin/migrate/process/EntityLookup.php, line 172

Class

EntityLookup
This plugin looks for existing entities.

Namespace

Drupal\migrate_plus\Plugin\migrate\process

Code

public function transform($value, MigrateExecutableInterface $migrateExecutable, Row $row, $destinationProperty) {

  // If the source data is an empty array, return the same.
  if (gettype($value) === 'array' && count($value) === 0) {
    return [];
  }

  // In case of subfields ('field_reference/target_id'), extract the field
  // name only.
  $parts = explode('/', $destinationProperty);
  $destinationProperty = reset($parts);
  $this
    ->determineLookupProperties($destinationProperty);
  $this->destinationProperty = isset($this->configuration['destination_field']) ? $this->configuration['destination_field'] : NULL;
  return $this
    ->query($value);
}