function UrlResolver::getProviderByUrl
Same name in other branches
- 8.9.x core/modules/media/src/OEmbed/UrlResolver.php \Drupal\media\OEmbed\UrlResolver::getProviderByUrl()
- 10 core/modules/media/src/OEmbed/UrlResolver.php \Drupal\media\OEmbed\UrlResolver::getProviderByUrl()
- 11.x core/modules/media/src/OEmbed/UrlResolver.php \Drupal\media\OEmbed\UrlResolver::getProviderByUrl()
Overrides UrlResolverInterface::getProviderByUrl
1 call to UrlResolver::getProviderByUrl()
- 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 130
Class
- UrlResolver
- Converts oEmbed media URLs into endpoint-specific resource URLs.
Namespace
Drupal\media\OEmbedCode
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.