Skip to main content
Drupal API
User account menu
  • Log in

Breadcrumb

  1. Drupal Core 11.1.x
  2. UrlResolver.php

function 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);
}

API Navigation

  • Drupal Core 11.1.x
  • Topics
  • Classes
  • Functions
  • Constants
  • Globals
  • Files
  • Namespaces
  • Deprecated
  • Services
RSS feed
Powered by Drupal