You are here

protected function ParserBase::executeSources in Feeds extensible parsers 8

Executes the source expressions.

Parameters

mixed $row: A single item returned from the context expression.

array $expressions: A map of machine name to expression.

array $variable_map: A map of machine name to varible name.

Return value

array The fully-parsed item array.

3 calls to ParserBase::executeSources()
JmesPathLinesParser::parseItems in src/Feeds/Parser/JmesPathLinesParser.php
Performs the actual parsing.
JsonPathLinesParser::parseItems in src/Feeds/Parser/JsonPathLinesParser.php
Performs the actual parsing.
ParserBase::parseItems in src/Feeds/Parser/ParserBase.php
Performs the actual parsing.

File

src/Feeds/Parser/ParserBase.php, line 353

Class

ParserBase
The Feeds extensible parser.

Namespace

Drupal\feeds_ex\Feeds\Parser

Code

protected function executeSources($row, array $expressions, array $variable_map) {
  $item = new DynamicItem();
  $variables = [];
  foreach ($expressions as $machine_name => $expression) {

    // Variable substitution.
    $expression = strtr($expression, $variables);
    $result = $this
      ->executeSourceExpression($machine_name, $expression, $row);
    if (!empty($this->configuration['sources'][$machine_name]['debug'])) {
      $this
        ->debug($result, $machine_name);
    }
    if ($result === NULL) {
      $variables[$variable_map[$machine_name]] = '';
      continue;
    }
    $item
      ->set($machine_name, $result);
    $variables[$variable_map[$machine_name]] = is_array($result) ? reset($result) : $result;
  }
  return $item;
}