class UrlResolver in Drupal 8
Same name in this branch
- 8 core/modules/media/src/OEmbed/UrlResolver.php \Drupal\media\OEmbed\UrlResolver
- 8 core/modules/media/tests/modules/media_test_oembed/src/UrlResolver.php \Drupal\media_test_oembed\UrlResolver
Same name and namespace in other branches
- 9 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
- class \Drupal\media\OEmbed\UrlResolver implements UrlResolverInterface uses UseCacheBackendTrait
- class \Drupal\media_test_oembed\UrlResolver
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_oembedView 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
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
UrlResolver:: |
protected | property | The HTTP client. | |
UrlResolver:: |
protected | property | The module handler service. | |
UrlResolver:: |
protected | property | The OEmbed provider repository service. | |
UrlResolver:: |
protected | property | The OEmbed resource fetcher service. | |
UrlResolver:: |
protected | property | Static cache of discovered oEmbed resource URLs, keyed by canonical URL. | |
UrlResolver:: |
protected | function | Runs oEmbed discovery and returns the endpoint URL if successful. | |
UrlResolver:: |
protected | function | Tries to find the oEmbed URL in a DOM. | |
UrlResolver:: |
public | function |
Tries to determine the oEmbed provider for a media asset URL. Overrides UrlResolverInterface:: |
|
UrlResolver:: |
public | function |
Builds the resource URL for a media asset URL. Overrides UrlResolver:: |
|
UrlResolver:: |
public static | function | Sets the endpoint URL for an oEmbed resource URL. | |
UrlResolver:: |
public | function | Constructs a UrlResolver object. | |
UseCacheBackendTrait:: |
protected | property | Cache backend instance. | |
UseCacheBackendTrait:: |
protected | property | Flag whether caches should be used or skipped. | |
UseCacheBackendTrait:: |
protected | function | Fetches from the cache backend, respecting the use caches flag. | 1 |
UseCacheBackendTrait:: |
protected | function | Stores data in the persistent cache, respecting the use caches flag. |