class ResourceFetcher implements ResourceFetcherInterface (View source)

Fetches and caches oEmbed resources.

Properties

protected Client $httpClient

The HTTP client.

protected ProviderRepositoryInterface $providers

The oEmbed provider repository service.

protected CacheBackendInterface $cacheBackend

The cache backend.

Methods

__construct(ClientInterface $http_client, ProviderRepositoryInterface $providers, CacheBackendInterface $cache_backend = NULL)

Constructs a ResourceFetcher object.

fetchResource(string $url)

Fetches an oEmbed resource.

createResource(array $data, string $url)

Creates a Resource object from raw resource data.

array
parseResourceXml(string $data, string $url)

Parses XML resource data.

Details

__construct(ClientInterface $http_client, ProviderRepositoryInterface $providers, CacheBackendInterface $cache_backend = NULL)

Constructs a ResourceFetcher object.

Parameters

ClientInterface $http_client

The HTTP client.

ProviderRepositoryInterface $providers

The oEmbed provider repository service.

CacheBackendInterface $cache_backend

The cache backend.

Resource fetchResource(string $url)

Fetches an oEmbed resource.

Parameters

string $url

Endpoint-specific URL of the oEmbed resource.

Return Value

Resource

A resource object built from the oEmbed resource data.

Exceptions

ResourceException

protected Resource createResource(array $data, string $url)

Creates a Resource object from raw resource data.

Parameters

array $data

The resource data returned by the provider.

string $url

The URL of the resource.

Return Value

Resource

A value object representing the resource.

Exceptions

ResourceException

protected array parseResourceXml(string $data, string $url)

Parses XML resource data.

Parameters

string $data

The raw XML for the resource.

string $url

The resource URL.

Return Value

array

The parsed resource data.

Exceptions

ResourceException