class UrlResolver

Same name in this branch
  1. 9 core/modules/media/src/OEmbed/UrlResolver.php \Drupal\media\OEmbed\UrlResolver
Same name in other branches
  1. 8.9.x core/modules/media/src/OEmbed/UrlResolver.php \Drupal\media\OEmbed\UrlResolver
  2. 8.9.x core/modules/media/tests/modules/media_test_oembed/src/UrlResolver.php \Drupal\media_test_oembed\UrlResolver
  3. 10 core/modules/media/src/OEmbed/UrlResolver.php \Drupal\media\OEmbed\UrlResolver
  4. 10 core/modules/media/tests/modules/media_test_oembed/src/UrlResolver.php \Drupal\media_test_oembed\UrlResolver
  5. 11.x core/modules/media/src/OEmbed/UrlResolver.php \Drupal\media\OEmbed\UrlResolver
  6. 11.x core/modules/media/tests/modules/media_test_oembed/src/UrlResolver.php \Drupal\media_test_oembed\UrlResolver

Overrides the oEmbed URL resolver service for testing purposes.

Hierarchy

Expanded class hierarchy of UrlResolver

1 file declares its use of UrlResolver
OEmbedFormatterTest.php in core/modules/media/tests/src/Functional/FieldFormatter/OEmbedFormatterTest.php

File

core/modules/media/tests/modules/media_test_oembed/src/UrlResolver.php, line 10

Namespace

Drupal\media_test_oembed
View source
class UrlResolver extends BaseUrlResolver {
    
    /**
     * Sets the endpoint URL for an oEmbed resource URL.
     *
     * @param string $url
     *   The resource URL.
     * @param string $endpoint_url
     *   The endpoint URL.
     */
    public static function setEndpointUrl($url, $endpoint_url) {
        $urls = \Drupal::state()->get(static::class, []);
        $urls[$url] = $endpoint_url;
        \Drupal::state()->set(static::class, $urls);
    }
    
    /**
     * {@inheritdoc}
     */
    public function getResourceUrl($url, $max_width = NULL, $max_height = NULL) {
        $urls = \Drupal::state()->get(static::class, []);
        if (isset($urls[$url])) {
            return $urls[$url];
        }
        return parent::getResourceUrl($url, $max_width, $max_height);
    }

}

Members

Title Sort descending Modifiers Object type Summary Overriden Title
UrlResolver::$cacheBackend protected property The cache backend.
UrlResolver::$httpClient protected property The HTTP client.
UrlResolver::$moduleHandler protected property The module handler service.
UrlResolver::$providers protected property The OEmbed provider repository service.
UrlResolver::$resourceFetcher protected property The OEmbed resource fetcher service.
UrlResolver::$urlCache protected property Static cache of discovered oEmbed resource URLs, keyed by canonical URL.
UrlResolver::discoverResourceUrl protected function Runs oEmbed discovery and returns the endpoint URL if successful.
UrlResolver::findUrl protected function Tries to find the oEmbed URL in a DOM.
UrlResolver::getEndpointMatchingUrl protected function For the given media item URL find an endpoint with schemes that match.
UrlResolver::getProviderByUrl public function Tries to determine the oEmbed provider for a media asset URL. Overrides UrlResolverInterface::getProviderByUrl
UrlResolver::getResourceUrl public function Builds the resource URL for a media asset URL. Overrides UrlResolver::getResourceUrl
UrlResolver::setEndpointUrl public static function Sets the endpoint URL for an oEmbed resource URL.
UrlResolver::__construct public function Constructs a UrlResolver object.

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.