You are here

protected function FeedsExecutable::doParse in Feeds 8.3

Parses.

Parameters

\Drupal\feeds\FeedInterface $feed: The feed to perform a parse event on.

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

1 call to FeedsExecutable::doParse()
FeedsExecutable::processItem in src/FeedsExecutable.php
Processes a stage of an import.

File

src/FeedsExecutable.php, line 240

Class

FeedsExecutable
Defines a feeds executable class.

Namespace

Drupal\feeds

Code

protected function doParse(FeedInterface $feed, FetcherResultInterface $fetcher_result) {
  $this
    ->dispatchEvent(FeedsEvents::INIT_IMPORT, new InitEvent($feed, 'parse'));
  $parse_event = $this
    ->dispatchEvent(FeedsEvents::PARSE, new ParseEvent($feed, $fetcher_result));
  $feed
    ->saveStates();
  $batch = $this
    ->createBatch($feed, static::PROCESS);
  foreach ($parse_event
    ->getParserResult() as $item) {
    $batch
      ->addOperation(static::PROCESS, [
      'item' => $item,
    ]);
  }

  // Add a final item that finalizes the import.
  $batch
    ->addOperation(static::FINISH, [
    'fetcher_result' => $fetcher_result,
  ]);
  $batch
    ->run();
}