You are here

public function Row::getMultiple in Drupal 9

Same name and namespace in other branches
  1. 8 core/modules/migrate/src/Row.php \Drupal\migrate\Row::getMultiple()

Retrieve multiple source and destination properties at once.

Parameters

string[] $properties: An array of values to retrieve, with destination values prefixed with @.

Return value

array An array of property values, keyed by property name.

1 call to Row::getMultiple()
Row::get in core/modules/migrate/src/Row.php
Retrieve a source or destination property.

File

core/modules/migrate/src/Row.php, line 340

Class

Row
Stores a row.

Namespace

Drupal\migrate

Code

public function getMultiple(array $properties) {
  $return = [];
  foreach ($properties as $orig_property) {
    $property = $orig_property;
    $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[$orig_property] = $this
        ->getSourceProperty($property);
    }
    else {
      $return[$orig_property] = $this
        ->getDestinationProperty($property);
    }
  }
  return $return;
}