You are here

protected function UrlResolver::findUrl in Drupal 8

Same name and namespace in other branches
  1. 9 core/modules/media/src/OEmbed/UrlResolver.php \Drupal\media\OEmbed\UrlResolver::findUrl()
  2. 10 core/modules/media/src/OEmbed/UrlResolver.php \Drupal\media\OEmbed\UrlResolver::findUrl()

Tries to find the oEmbed URL in a DOM.

Parameters

\DOMXPath $xpath: Page HTML as DOMXPath.

string $format: Format of oEmbed resource. Possible values are 'json' and 'xml'.

Return value

bool|string A URL to an oEmbed resource or FALSE if not found.

1 call to UrlResolver::findUrl()
UrlResolver::discoverResourceUrl in core/modules/media/src/OEmbed/UrlResolver.php
Runs oEmbed discovery and returns the endpoint URL if successful.

File

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

Class

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

Namespace

Drupal\media\OEmbed

Code

protected function findUrl(\DOMXPath $xpath, $format) {
  $result = $xpath
    ->query("//link[@type='application/{$format}+oembed']");
  return $result->length ? $result
    ->item(0)
    ->getAttribute('href') : FALSE;
}