function UrlResolver::discoverResourceUrl
Same name in other branches
- 9 core/modules/media/src/OEmbed/UrlResolver.php \Drupal\media\OEmbed\UrlResolver::discoverResourceUrl()
- 10 core/modules/media/src/OEmbed/UrlResolver.php \Drupal\media\OEmbed\UrlResolver::discoverResourceUrl()
- 11.x core/modules/media/src/OEmbed/UrlResolver.php \Drupal\media\OEmbed\UrlResolver::discoverResourceUrl()
Runs oEmbed discovery and returns the endpoint URL if successful.
Parameters
string $url: The resource's URL.
Return value
string|bool URL of the oEmbed endpoint, or FALSE if the discovery was unsuccessful.
1 call to UrlResolver::discoverResourceUrl()
- UrlResolver::getProviderByUrl in core/
modules/ media/ src/ OEmbed/ UrlResolver.php - Tries to determine the oEmbed provider for a media asset URL.
File
-
core/
modules/ media/ src/ OEmbed/ UrlResolver.php, line 90
Class
- UrlResolver
- Converts oEmbed media URLs into endpoint-specific resource URLs.
Namespace
Drupal\media\OEmbedCode
protected function discoverResourceUrl($url) {
try {
$response = $this->httpClient
->get($url);
} catch (RequestException $e) {
return FALSE;
}
$document = Html::load((string) $response->getBody());
$xpath = new \DOMXpath($document);
return $this->findUrl($xpath, 'json') ?: $this->findUrl($xpath, 'xml');
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.