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

Breadcrumb

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

function 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

File

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

Class

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

Namespace

Drupal\media\OEmbed

Code

protected function discoverResourceUrl($url) {
    try {
        $response = $this->httpClient
            ->get($url);
    } catch (ClientExceptionInterface) {
        return FALSE;
    }
    $document = Html::load((string) $response->getBody());
    $xpath = new \DOMXpath($document);
    return $this->findUrl($xpath, 'json') ?: $this->findUrl($xpath, 'xml');
}

API Navigation

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