You are here

protected function FeedsCrawlerPattern::getNextUrl in Feeds Crawler 7.2

Subclasses must override this to return the next URL.

Parameters

FeedsSource $source: The feed source.

string $current_url: The current URL being fetched.

Return value

string The next URL.

Throws

FeedsCrawlerLinkNotFoundException Thrown if the next link could not be found.

Overrides FeedsCrawlerBase::getNextUrl

File

src/FeedsCrawlerPattern.php, line 47
Contains FeedsCrawlerPattern.

Class

FeedsCrawlerPattern
Crawls links using a URL pattern.

Code

protected function getNextUrl(FeedsSource $source, $current_url) {
  $source_config = $source
    ->getConfigFor($this);
  foreach (array(
    'pattern',
    'initial_index',
    'increment',
  ) as $key) {
    if (!isset($source_config[$key]) || !strlen($source_config[$key])) {
      throw new FeedsCrawlerLinkNotFoundException();
    }
  }
  $parts = parse_url($current_url) + self::$defaultParts;
  $tokens = array();
  foreach ($parts as $key => $value) {
    $tokens['{' . $key . '}'] = $value;
  }
  $drupal_parts = drupal_parse_url($current_url);
  $tokens['{full_path}'] = $drupal_parts['path'];
  $tokens['{index}'] = $source
    ->state(FEEDS_FETCH)->index;
  return strtr($source_config['pattern'], $tokens);
}