You are here

public function UploadFetcher::fetch in Feeds 8.3

Fetch content from a feed and return it.

Parameters

\Drupal\feeds\FeedInterface $feed: The feed to fetch results for.

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

Return value

\Drupal\feeds\Result\FetcherResultInterface A fetcher result object.

Overrides FetcherInterface::fetch

File

src/Feeds/Fetcher/UploadFetcher.php, line 95

Class

UploadFetcher
Defines a file upload fetcher.

Namespace

Drupal\feeds\Feeds\Fetcher

Code

public function fetch(FeedInterface $feed, StateInterface $state) {
  $file = $feed
    ->getSource();
  if (is_file($file) && is_readable($file)) {
    return new FetcherResult($file);
  }

  // File does not exist.
  throw new \RuntimeException(new FormattableMarkup('Resource is not a file: %source', [
    '%source' => $file,
  ]));
}