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

Breadcrumb

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

function UrlResolver::getEndpointMatchingUrl

For the given media item URL find an endpoint with schemes that match.

Parameters

string $url: The media URL used to lookup the matching endpoint.

\Drupal\media\OEmbed\Provider $provider: The oEmbed provider for the asset.

Return value

string The resource URL.

1 call to UrlResolver::getEndpointMatchingUrl()
UrlResolver::getResourceUrl in core/modules/media/src/OEmbed/UrlResolver.php

File

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

Class

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

Namespace

Drupal\media\OEmbed

Code

protected function getEndpointMatchingUrl($url, Provider $provider) {
    $endpoints = $provider->getEndpoints();
    $resource_url = reset($endpoints)->buildResourceUrl($url);
    foreach ($endpoints as $endpoint) {
        if ($endpoint->matchUrl($url)) {
            $resource_url = $endpoint->buildResourceUrl($url);
            break;
        }
    }
    return $resource_url ?? reset($endpoints)->buildResourceUrl($url);
}

API Navigation

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