ProviderRepository.php in Drupal 10
File
core/modules/media/tests/modules/media_test_oembed/src/ProviderRepository.php
View source
<?php
namespace Drupal\media_test_oembed;
use Drupal\media\OEmbed\Provider;
use Drupal\media\OEmbed\ProviderRepository as BaseProviderRepository;
class ProviderRepository extends BaseProviderRepository {
public function getAll() {
return \Drupal::state()
->get(static::class) ?: parent::getAll();
}
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);
}
public function setProvider(Provider $provider) {
$providers = \Drupal::state()
->get(static::class, []);
$name = $provider
->getName();
$providers[$name] = $provider;
\Drupal::state()
->set(static::class, $providers);
}
}