You are here

protected function UrlResolver::getEndpointMatchingUrl in Drupal 10

Same name and namespace in other branches
  1. 9 core/modules/media/src/OEmbed/UrlResolver.php \Drupal\media\OEmbed\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
Builds the resource URL for a media asset URL.

File

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

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