You are here

protected function FileImport::getPropertyValue in Migrate Files (extended) 8

Same name and namespace in other branches
  1. 2.0.x src/Plugin/migrate/process/FileImport.php \Drupal\migrate_file\Plugin\migrate\process\FileImport::getPropertyValue()

Gets a value from a source or destination property.

Code is adapted from Drupal\migrate\Plugin\migrate\process\Get::transform()

2 calls to FileImport::getPropertyValue()
FileImport::transform in src/Plugin/migrate/process/FileImport.php
Performs the associated process.
ImageImport::transform in src/Plugin/migrate/process/ImageImport.php
Performs the associated process.

File

src/Plugin/migrate/process/FileImport.php, line 259

Class

FileImport
Imports a file from an local or external source.

Namespace

Drupal\migrate_file\Plugin\migrate\process

Code

protected function getPropertyValue($property, $row) {
  if ($property || (string) $property === '0') {
    $is_source = TRUE;
    if ($property[0] == '@') {
      $property = preg_replace_callback('/^(@?)((?:@@)*)([^@]|$)/', function ($matches) use (&$is_source) {

        // If there are an odd number of @ in the beginning, it's a
        // destination.
        $is_source = empty($matches[1]);

        // Remove the possible escaping and do not lose the terminating
        // non-@ either.
        return str_replace('@@', '@', $matches[2]) . $matches[3];
      }, $property);
    }
    if ($is_source) {
      return $row
        ->getSourceProperty($property);
    }
    else {
      return $row
        ->getDestinationProperty($property);
    }
  }
  return FALSE;
}