class UrlResolver

Same name in this branch
  1. 9 core/modules/media/src/OEmbed/UrlResolver.php \Drupal\media\OEmbed\UrlResolver
Same name and namespace in other branches
  1. 10 core/modules/media/src/OEmbed/UrlResolver.php \Drupal\media\OEmbed\UrlResolver
  2. 10 core/modules/media/tests/modules/media_test_oembed/src/UrlResolver.php \Drupal\media_test_oembed\UrlResolver
  3. 11.x core/modules/media/src/OEmbed/UrlResolver.php \Drupal\media\OEmbed\UrlResolver
  4. 11.x core/modules/media/tests/modules/media_test_oembed/src/UrlResolver.php \Drupal\media_test_oembed\UrlResolver
  5. 8.9.x core/modules/media/src/OEmbed/UrlResolver.php \Drupal\media\OEmbed\UrlResolver
  6. 8.9.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);
  }

}

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