function UrlResolver::getProviderByUrl

Same name in other branches
  1. 9 core/modules/media/src/OEmbed/UrlResolver.php \Drupal\media\OEmbed\UrlResolver::getProviderByUrl()
  2. 8.9.x core/modules/media/src/OEmbed/UrlResolver.php \Drupal\media\OEmbed\UrlResolver::getProviderByUrl()
  3. 11.x core/modules/media/src/OEmbed/UrlResolver.php \Drupal\media\OEmbed\UrlResolver::getProviderByUrl()
1 call to UrlResolver::getProviderByUrl()
UrlResolver::getResourceUrl in core/modules/media/src/OEmbed/UrlResolver.php

File

core/modules/media/src/OEmbed/UrlResolver.php, line 128

Class

UrlResolver
Converts oEmbed media URLs into endpoint-specific resource URLs.

Namespace

Drupal\media\OEmbed

Code

public function getProviderByUrl($url) {
    // Check the URL against every scheme of every endpoint of every provider
    // until we find a match.
    foreach ($this->providers
        ->getAll() as $provider_info) {
        foreach ($provider_info->getEndpoints() as $endpoint) {
            if ($endpoint->matchUrl($url)) {
                return $provider_info;
            }
        }
    }
    $resource_url = $this->discoverResourceUrl($url);
    if ($resource_url) {
        return $this->resourceFetcher
            ->fetchResource($resource_url)
            ->getProvider();
    }
    throw new ResourceException('No matching provider found.', $url);
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.