class ProviderRepository in Drupal 10
Same name in this branch
- 10 core/modules/media/src/OEmbed/ProviderRepository.php \Drupal\media\OEmbed\ProviderRepository
- 10 core/modules/media/tests/modules/media_test_oembed/src/ProviderRepository.php \Drupal\media_test_oembed\ProviderRepository
Same name and namespace in other branches
- 8 core/modules/media/tests/modules/media_test_oembed/src/ProviderRepository.php \Drupal\media_test_oembed\ProviderRepository
- 9 core/modules/media/tests/modules/media_test_oembed/src/ProviderRepository.php \Drupal\media_test_oembed\ProviderRepository
Overrides the oEmbed provider repository service for testing purposes.
This service does not use caching at all, and will always try to retrieve provider data from state before calling the parent methods.
Hierarchy
- class \Drupal\media\OEmbed\ProviderRepository implements ProviderRepositoryInterface
- class \Drupal\media_test_oembed\ProviderRepository
Expanded class hierarchy of ProviderRepository
File
- core/
modules/ media/ tests/ modules/ media_test_oembed/ src/ ProviderRepository.php, line 14
Namespace
Drupal\media_test_oembedView source
class ProviderRepository extends BaseProviderRepository {
/**
* {@inheritdoc}
*/
public function getAll() {
return \Drupal::state()
->get(static::class) ?: parent::getAll();
}
/**
* {@inheritdoc}
*/
public function get($provider_name) {
$providers = \Drupal::state()
->get(static::class, []);
if (isset($providers[$provider_name])) {
return $providers[$provider_name];
}
return parent::get($provider_name);
}
/**
* Stores an oEmbed provider value object in state.
*
* @param \Drupal\media\OEmbed\Provider $provider
* The provider to store.
*/
public function setProvider(Provider $provider) {
$providers = \Drupal::state()
->get(static::class, []);
$name = $provider
->getName();
$providers[$name] = $provider;
\Drupal::state()
->set(static::class, $providers);
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
ProviderRepository:: |
protected | property | The HTTP client. | |
ProviderRepository:: |
protected | property | The key-value store. | |
ProviderRepository:: |
protected | property | The logger channel. | |
ProviderRepository:: |
protected | property | How long the provider data should be cached, in seconds. | |
ProviderRepository:: |
protected | property | URL of a JSON document which contains a database of oEmbed providers. | |
ProviderRepository:: |
protected | property | The time service. | |
ProviderRepository:: |
public | function |
Returns information for a specific oEmbed provider. Overrides ProviderRepository:: |
|
ProviderRepository:: |
public | function |
Returns information on all available oEmbed providers. Overrides ProviderRepository:: |
|
ProviderRepository:: |
public | function | Stores an oEmbed provider value object in state. | |
ProviderRepository:: |
public | function | Constructs a ProviderRepository instance. |