You are here

protected function FeedsExXml::executeContext in Feeds extensible parsers 7.2

Same name and namespace in other branches
  1. 7 src/FeedsExXml.inc \FeedsExXml::executeContext()

Returns rows to be parsed.

Parameters

FeedsSource $source: Source information.

FeedsFetcherResult $fetcher_result: The result returned by the fetcher.

Return value

array|Traversable Some iterable that returns rows.

Overrides FeedsExBase::executeContext

1 method overrides FeedsExXml::executeContext()
FeedsExQueryPathXml::executeContext in src/FeedsExQueryPathXml.inc
Returns rows to be parsed.

File

src/FeedsExXml.inc, line 58
Contains FeedsExXml.

Class

FeedsExXml
Parses XML documents with XPath.

Code

protected function executeContext(FeedsSource $source, FeedsFetcherResult $fetcher_result) {
  $state = $source
    ->state(FEEDS_PARSE);
  if (!$state->total) {
    $state->total = $this->xpath
      ->evaluate('count(' . $this->config['context']['value'] . ')');
  }
  $start = $state->pointer ? $state->pointer : 0;
  $limit = $start + $source->importer
    ->getLimit();
  $end = $limit > $state->total ? $state->total : $limit;
  $state->pointer = $end;

  // A batched XPath expression.
  $context_query = '(' . $this->config['context']['value'] . ")[position() > {$start} and position() <= {$end}]";
  return $this->xpath
    ->query($context_query);
}