class Endpoint (View source)

internal  This class is an internal part of the oEmbed system and should only be instantiated by instances of Drupal\media\OEmbed\Provider.
 

Value object for oEmbed provider endpoints.

Properties

protected string $url

The endpoint's URL.

protected Provider $provider

The provider this endpoint belongs to.

protected string[] $schemes

List of URL schemes supported by the provider.

protected string[] $formats

List of supported formats. Only 'json' and 'xml' are allowed.

protected bool $supportsDiscovery

Whether the provider supports oEmbed discovery.

Methods

__construct(string $url, Provider $provider, array $schemes = [], array $formats = [], bool $supports_discovery = FALSE)

Endpoint constructor.

string
getUrl()

Returns the endpoint URL.

getProvider()

Returns the provider this endpoint belongs to.

string[]
getSchemes()

Returns list of URL schemes supported by the provider.

string[]
getFormats()

Returns list of supported formats.

bool
supportsDiscovery()

Returns whether the provider supports oEmbed discovery.

bool
matchUrl(string $url)

Tries to match a URL against the endpoint schemes.

string
buildResourceUrl(string $url)

Builds and returns the endpoint URL.

Details

__construct(string $url, Provider $provider, array $schemes = [], array $formats = [], bool $supports_discovery = FALSE)

Endpoint constructor.

Parameters

string $url

The endpoint URL. May contain a @code '{format}' @endcode placeholder.

Provider $provider

The provider this endpoint belongs to.

array $schemes

List of URL schemes supported by the provider.

array $formats

List of supported formats. Can be "json", "xml" or both.

bool $supports_discovery

Whether the provider supports oEmbed discovery.

Exceptions

InvalidArgumentException

string getUrl()

Returns the endpoint URL.

The URL will be built with the first available format. If the endpoint does not provide any formats, JSON will be used.

Return Value

string

The endpoint URL.

Provider getProvider()

Returns the provider this endpoint belongs to.

Return Value

Provider

The provider object.

string[] getSchemes()

Returns list of URL schemes supported by the provider.

Return Value

string[]

List of schemes.

string[] getFormats()

Returns list of supported formats.

Return Value

string[]

List of formats.

bool supportsDiscovery()

Returns whether the provider supports oEmbed discovery.

Return Value

bool

Returns TRUE if the provides discovery, otherwise FALSE.

bool matchUrl(string $url)

Tries to match a URL against the endpoint schemes.

Parameters

string $url

Media item URL.

Return Value

bool

TRUE if the URL matches against the endpoint schemes, otherwise FALSE.

string buildResourceUrl(string $url)

Builds and returns the endpoint URL.

In most situations this function should not be used. Your are probably looking for \Drupal\media\OEmbed\UrlResolver::getResourceUrl(), because it is alterable and also cached.

Parameters

string $url

The canonical media URL.

Return Value

string

URL of the oEmbed endpoint.

See also

UrlResolver::getResourceUrl