UrlResolver.php

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

Namespace

Drupal\media_test_oembed

File

core/modules/media/tests/modules/media_test_oembed/src/UrlResolver.php

View source
<?php

declare (strict_types=1);
namespace Drupal\media_test_oembed;

use Drupal\media\OEmbed\UrlResolver as BaseUrlResolver;

/**
 * Overrides the oEmbed URL resolver service for testing purposes.
 */
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);
    }

}

Classes

Title Deprecated Summary
UrlResolver Overrides the oEmbed URL resolver service for testing purposes.

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