UrlResolver
class UrlResolver implements UrlResolverInterface (View source)
Converts oEmbed media URLs into endpoint-specific resource URLs.
Traits
Provides methods to use a cache backend while respecting a 'use caches' flag.
Properties
| protected CacheBackendInterface | $cacheBackend | Cache backend instance. |
from UseCacheBackendTrait |
| protected bool | $useCaches | Flag whether caches should be used or skipped. |
from UseCacheBackendTrait |
| protected Client | $httpClient | The HTTP client. |
|
| protected ProviderRepositoryInterface | $providers | The OEmbed provider repository service. |
|
| protected ResourceFetcherInterface | $resourceFetcher | The OEmbed resource fetcher service. |
|
| protected ModuleHandlerInterface | $moduleHandler | The module handler service. |
|
| protected string[] | $urlCache | Static cache of discovered oEmbed resource URLs, keyed by canonical URL. |
Methods
Fetches from the cache backend, respecting the use caches flag.
Stores data in the persistent cache, respecting the use caches flag.
Constructs a UrlResolver object.
Runs oEmbed discovery and returns the endpoint URL if successful.
Tries to determine the oEmbed provider for a media asset URL.
Builds the resource URL for a media asset URL.
Details
protected object|false
cacheGet(string $cid)
Fetches from the cache backend, respecting the use caches flag.
protected
cacheSet(string $cid, mixed $data, int $expire = Cache::PERMANENT, array $tags = [])
Stores data in the persistent cache, respecting the use caches flag.
__construct(ProviderRepositoryInterface $providers, ResourceFetcherInterface $resource_fetcher, ClientInterface $http_client, ModuleHandlerInterface $module_handler, CacheBackendInterface $cache_backend = NULL)
Constructs a UrlResolver object.
protected string|bool
discoverResourceUrl(string $url)
Runs oEmbed discovery and returns the endpoint URL if successful.
protected bool|string
findUrl(DOMXPath $xpath, string $format)
Tries to find the oEmbed URL in a DOM.
Provider
getProviderByUrl(string $url)
Tries to determine the oEmbed provider for a media asset URL.
string
getResourceUrl(string $url, int $max_width = NULL, int $max_height = NULL)
Builds the resource URL for a media asset URL.