function ProviderRepository::getAll
Same name in this branch
- 8.9.x core/modules/media/tests/modules/media_test_oembed/src/ProviderRepository.php \Drupal\media_test_oembed\ProviderRepository::getAll()
Same name in other branches
- 9 core/modules/media/src/OEmbed/ProviderRepository.php \Drupal\media\OEmbed\ProviderRepository::getAll()
- 9 core/modules/media/tests/modules/media_test_oembed/src/ProviderRepository.php \Drupal\media_test_oembed\ProviderRepository::getAll()
- 10 core/modules/media/src/OEmbed/ProviderRepository.php \Drupal\media\OEmbed\ProviderRepository::getAll()
- 10 core/modules/media/tests/modules/media_test_oembed/src/ProviderRepository.php \Drupal\media_test_oembed\ProviderRepository::getAll()
- 11.x core/modules/media/src/OEmbed/ProviderRepository.php \Drupal\media\OEmbed\ProviderRepository::getAll()
- 11.x core/modules/media/tests/modules/media_test_oembed/src/ProviderRepository.php \Drupal\media_test_oembed\ProviderRepository::getAll()
Overrides ProviderRepositoryInterface::getAll
2 calls to ProviderRepository::getAll()
- ProviderRepository::get in core/
modules/ media/ src/ OEmbed/ ProviderRepository.php - Returns information for a specific oEmbed provider.
- ProviderRepository::getAll in core/
modules/ media/ tests/ modules/ media_test_oembed/ src/ ProviderRepository.php - Returns information on all available oEmbed providers.
1 method overrides ProviderRepository::getAll()
- ProviderRepository::getAll in core/
modules/ media/ tests/ modules/ media_test_oembed/ src/ ProviderRepository.php - Returns information on all available oEmbed providers.
File
-
core/
modules/ media/ src/ OEmbed/ ProviderRepository.php, line 73
Class
- ProviderRepository
- Retrieves and caches information about oEmbed providers.
Namespace
Drupal\media\OEmbedCode
public function getAll() {
$cache_id = 'media:oembed_providers';
$cached = $this->cacheGet($cache_id);
if ($cached) {
return $cached->data;
}
try {
$response = $this->httpClient
->request('GET', $this->providersUrl);
} catch (RequestException $e) {
throw new ProviderException("Could not retrieve the oEmbed provider database from {$this->providersUrl}", NULL, $e);
}
$providers = Json::decode((string) $response->getBody());
if (!is_array($providers) || empty($providers)) {
throw new ProviderException('Remote oEmbed providers database returned invalid or empty list.');
}
$keyed_providers = [];
foreach ($providers as $provider) {
try {
$name = (string) $provider['provider_name'];
$keyed_providers[$name] = new Provider($provider['provider_name'], $provider['provider_url'], $provider['endpoints']);
} catch (ProviderException $e) {
// Just skip all the invalid providers.
// @todo Log the exception message to help with debugging.
}
}
$this->cacheSet($cache_id, $keyed_providers, $this->time
->getCurrentTime() + $this->maxAge);
return $keyed_providers;
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.