You are here

protected function JsonPathParser::executeContext in Feeds extensible parsers 8

Returns rows to be parsed.

Parameters

\Drupal\feeds\FeedInterface $feed: Source information.

\Drupal\feeds\Result\FetcherResultInterface $fetcher_result: The result returned by the fetcher.

\Drupal\feeds\StateInterface $state: The state object.

Return value

array|Traversable Some iterable that returns rows.

Overrides ParserBase::executeContext

File

src/Feeds/Parser/JsonPathParser.php, line 28

Class

JsonPathParser
Defines a JSON parser using JSONPath.

Namespace

Drupal\feeds_ex\Feeds\Parser

Code

protected function executeContext(FeedInterface $feed, FetcherResultInterface $fetcher_result, StateInterface $state) {
  $raw = $this
    ->prepareRaw($fetcher_result);
  $parsed = $this->utility
    ->decodeJsonArray($raw);
  $parsed = $this
    ->search($parsed, $this->configuration['context']['value']);
  if (!$state->total) {
    $state->total = count($parsed);
  }
  $start = (int) $state->pointer;
  $state->pointer = $start + $this->configuration['line_limit'];
  return array_slice($parsed, $start, $this->configuration['line_limit']);
}