You are here

public function FeedsExecutable::processItem in Feeds 8.3

Processes a stage of an import.

Parameters

\Drupal\feeds\FeedInterface $feed: The feed to batch.

string $stage: The stage which the import is at.

array $params: Parameters relevant to the current stage.

Overrides FeedsExecutableInterface::processItem

File

src/FeedsExecutable.php, line 92

Class

FeedsExecutable
Defines a feeds executable class.

Namespace

Drupal\feeds

Code

public function processItem(FeedInterface $feed, $stage, array $params = []) {

  // Make sure that the feed type exists.
  $feed
    ->getType();
  $switcher = $this
    ->switchAccount($feed);
  try {
    switch ($stage) {
      case static::BEGIN:
        $this
          ->import($feed);
        break;
      case static::FETCH:
        $this
          ->doFetch($feed);
        break;
      case static::PARSE:
        $this
          ->doParse($feed, $params['fetcher_result']);
        break;
      case static::PROCESS:
        $this
          ->doProcess($feed, $params['item']);
        break;
      case static::CLEAN:
        $this
          ->doClean($feed);
        break;
      case static::FINISH:
        $this
          ->finish($feed, $params['fetcher_result']);
        break;
    }
  } catch (Exception $exception) {
    return $this
      ->handleException($feed, $stage, $params, $exception);
  } finally {
    $switcher
      ->switchBack();
  }
}