You are here

public static function Feed::translateSchemes in Feeds 8.3

Translates the scheme of feed-type URLs into HTTP.

Parameters

string $url: The URL to translate.

Return value

string The URL with the scheme translated.

Throws

\InvalidArgumentException Thrown then the URL contains an invalid scheme.

3 calls to Feed::translateSchemes()
HttpFetcher::get in src/Feeds/Fetcher/HttpFetcher.php
Performs a GET request.
HttpFetcherFeedForm::get in src/Feeds/Fetcher/Form/HttpFetcherFeedForm.php
Performs a GET request.
HttpFetcherFeedForm::validateConfigurationForm in src/Feeds/Fetcher/Form/HttpFetcherFeedForm.php
Form validation handler.

File

src/Utility/Feed.php, line 109

Class

Feed
Helper functions for dealing with feeds.

Namespace

Drupal\feeds\Utility

Code

public static function translateSchemes($url) {
  $uri = new Uri($url);
  switch ($uri
    ->getScheme()) {
    case 'http':
    case 'feed':
    case 'webcal':
      return (string) $uri
        ->withScheme('http');
    case 'https':
    case 'feeds':
    case 'webcals':
      return (string) $uri
        ->withScheme('https');
  }
  throw new \InvalidArgumentException();
}