class ProviderRepository in Drupal 8
Same name in this branch
- 8 core/modules/media/src/OEmbed/ProviderRepository.php \Drupal\media\OEmbed\ProviderRepository
- 8 core/modules/media/tests/modules/media_test_oembed/src/ProviderRepository.php \Drupal\media_test_oembed\ProviderRepository
Same name and namespace in other branches
- 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 uses UseCacheBackendTrait
- 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}
*/
protected function cacheGet($cid) {
return FALSE;
}
/**
* {@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 | 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:: |
protected | function |
Fetches from the cache backend, respecting the use caches flag. Overrides UseCacheBackendTrait:: |
|
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. | |
UseCacheBackendTrait:: |
protected | property | Cache backend instance. | |
UseCacheBackendTrait:: |
protected | property | Flag whether caches should be used or skipped. | |
UseCacheBackendTrait:: |
protected | function | Stores data in the persistent cache, respecting the use caches flag. |