You are here

public function ProviderRepositoryDecorator::getCustomProviders in oEmbed Providers 1.0.x

Same name and namespace in other branches
  1. 2.x src/OEmbed/ProviderRepositoryDecorator.php \Drupal\oembed_providers\OEmbed\ProviderRepositoryDecorator::getCustomProviders()
  2. 1.1.x src/OEmbed/ProviderRepositoryDecorator.php \Drupal\oembed_providers\OEmbed\ProviderRepositoryDecorator::getCustomProviders()

Returns custom providers in format identical to decoded providers.json.

Return value

array Custom providers.

1 call to ProviderRepositoryDecorator::getCustomProviders()
ProviderRepositoryDecorator::getAll in src/OEmbed/ProviderRepositoryDecorator.php
Returns information on all available oEmbed providers.

File

src/OEmbed/ProviderRepositoryDecorator.php, line 176

Class

ProviderRepositoryDecorator
Decorates the oEmbed ProviderRepository provided by core Media module.

Namespace

Drupal\oembed_providers\OEmbed

Code

public function getCustomProviders() {
  return array_map(function (OembedProvider $custom_provider) {
    $endpoints = array_map(function (array $endpointData) {
      $endpoint = [
        'schemes' => $endpointData['schemes'],
        'url' => $endpointData['url'],
        'formats' => array_keys(array_filter($endpointData['formats'])),
      ];
      if ($endpointData['discovery']) {
        $endpoint['discovery'] = $endpointData['discovery'];
      }
      return $endpoint;
    }, $custom_provider
      ->get('endpoints'));
    return [
      'provider_name' => $custom_provider
        ->get('label'),
      'provider_url' => $custom_provider
        ->get('provider_url'),
      'endpoints' => $endpoints,
    ];
  }, $this->oembedProviderStorage
    ->loadMultiple());
}