You are here

public function ProviderRepository::setProvider in Drupal 9

Same name and namespace in other branches
  1. 8 core/modules/media/tests/modules/media_test_oembed/src/ProviderRepository.php \Drupal\media_test_oembed\ProviderRepository::setProvider()

Stores an oEmbed provider value object in state.

Parameters

\Drupal\media\OEmbed\Provider $provider: The provider to store.

File

core/modules/media/tests/modules/media_test_oembed/src/ProviderRepository.php, line 41

Class

ProviderRepository
Overrides the oEmbed provider repository service for testing purposes.

Namespace

Drupal\media_test_oembed

Code

public function setProvider(Provider $provider) {
  $providers = \Drupal::state()
    ->get(static::class, []);
  $name = $provider
    ->getName();
  $providers[$name] = $provider;
  \Drupal::state()
    ->set(static::class, $providers);
}