function Row::getMultiple

Same name in other branches
  1. 9 core/modules/migrate/src/Row.php \Drupal\migrate\Row::getMultiple()
  2. 8.9.x core/modules/migrate/src/Row.php \Drupal\migrate\Row::getMultiple()
  3. 10 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 341

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;
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.