function ProviderRepository::setProvider

Same name in other branches
  1. 9 core/modules/media/tests/modules/media_test_oembed/src/ProviderRepository.php \Drupal\media_test_oembed\ProviderRepository::setProvider()
  2. 8.9.x core/modules/media/tests/modules/media_test_oembed/src/ProviderRepository.php \Drupal\media_test_oembed\ProviderRepository::setProvider()
  3. 11.x 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);
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.