PHP Class Essence\Provider\OEmbed

This kind of provider extracts embed informations through the OEmbed protocol.
Inheritance: extends Essence\Provider
ファイルを表示 Open project: benjamminf/craft-embedded-assets Class Usage Examples

Protected Properties

Property Type Description
$_Dom Essence\Dom\Document\Factory\Native DOM parser.
$_Http Essence\Http\Client HTTP client.
$_endpoint string The OEmbed endpoint.
$_format string The expected response format.

Public Methods

Method Description
__construct ( Essence\Http\Client $Http, Native $Dom ) Constructor.
setEndpoint ( string $endpoint ) Sets the endpoint.
setFormat ( string $format ) Sets the response format.

Protected Methods

Method Description
_buildConfig ( string $url ) : Config Builds an oEmbed configuration from settings.
_config ( string $url, array $options ) : Config Builds or extracts an oEmbed config.
_extract ( $url, array $options ) {@inheritDoc}
_extractConfig ( string $html ) : array Extracts an oEmbed configuration from the given page.
_extractFormat ( Tag $Link ) : Tag Extracts an oEmbed response format from a link tag.
_parse ( string $response, string $format ) : array Parses the given response depending on its format.

Method Details

__construct() public method

Constructor.
public __construct ( Essence\Http\Client $Http, Native $Dom )
$Http Essence\Http\Client HTTP client.
$Dom Essence\Dom\Document\Factory\Native DOM parser.

_buildConfig() protected method

Builds an oEmbed configuration from settings.
protected _buildConfig ( string $url ) : Config
$url string URL to extract.
return Essence\Provider\OEmbed\Config Configuration.

_config() protected method

Builds or extracts an oEmbed config.
protected _config ( string $url, array $options ) : Config
$url string URL.
$options array Options.
return Essence\Provider\OEmbed\Config Configuration.

_extract() protected method

{@inheritDoc}
protected _extract ( $url, array $options )
$options array

_extractConfig() protected method

Extracts an oEmbed configuration from the given page.
protected _extractConfig ( string $html ) : array
$html string HTML page.
return array Configuration.

_extractFormat() protected method

Extracts an oEmbed response format from a link tag.
protected _extractFormat ( Tag $Link ) : Tag
$Link Essence\Dom\Tag Link tag.
return Essence\Dom\Tag string|null Format.

_parse() protected method

Parses the given response depending on its format.
protected _parse ( string $response, string $format ) : array
$response string Response.
$format string Format.
return array Data.

setEndpoint() public method

Sets the endpoint.
public setEndpoint ( string $endpoint )
$endpoint string Endpoint.

setFormat() public method

Sets the response format.
public setFormat ( string $format )
$format string Format.

Property Details

$_Dom protected_oe property

DOM parser.
protected Native,Essence\Dom\Document\Factory $_Dom
return Essence\Dom\Document\Factory\Native

$_Http protected_oe property

HTTP client.
protected Client,Essence\Http $_Http
return Essence\Http\Client

$_endpoint protected_oe property

The OEmbed endpoint.
protected string $_endpoint
return string

$_format protected_oe property

The expected response format.
protected string $_format
return string