function ProviderRepository::__construct

Same name in other branches
  1. 8.9.x core/modules/media/src/OEmbed/ProviderRepository.php \Drupal\media\OEmbed\ProviderRepository::__construct()
  2. 10 core/modules/media/src/OEmbed/ProviderRepository.php \Drupal\media\OEmbed\ProviderRepository::__construct()
  3. 11.x core/modules/media/src/OEmbed/ProviderRepository.php \Drupal\media\OEmbed\ProviderRepository::__construct()

Constructs a ProviderRepository instance.

Parameters

\GuzzleHttp\ClientInterface $http_client: The HTTP client.

\Drupal\Core\Config\ConfigFactoryInterface $config_factory: The config factory service.

\Drupal\Component\Datetime\TimeInterface $time: The time service.

\Drupal\Core\KeyValueStore\KeyValueFactoryInterface $key_value_factory: The key-value store factory.

\Drupal\Core\Logger\LoggerChannelFactoryInterface $logger_factory: The logger channel factory.

int $max_age: (optional) How long the cache data should be kept. Defaults to a week.

File

core/modules/media/src/OEmbed/ProviderRepository.php, line 88

Class

ProviderRepository
Retrieves and caches information about oEmbed providers.

Namespace

Drupal\media\OEmbed

Code

public function __construct(ClientInterface $http_client, ConfigFactoryInterface $config_factory, TimeInterface $time, $key_value_factory = NULL, $logger_factory = NULL, int $max_age = 604800) {
    $this->httpClient = $http_client;
    $this->providersUrl = $config_factory->get('media.settings')
        ->get('oembed_providers_url');
    $this->time = $time;
    if (!$key_value_factory instanceof KeyValueFactoryInterface) {
        @trigger_error('The keyvalue service should be passed to ' . __METHOD__ . '() since drupal:9.3.0 and is required in drupal:10.0.0. See https://www.drupal.org/node/3186186', E_USER_DEPRECATED);
        $key_value_factory = \Drupal::service('keyvalue');
    }
    if (!$logger_factory instanceof LoggerChannelFactoryInterface) {
        // If $max_age was passed in $logger_factory's position, ensure that we
        // use the correct value.
        if (is_numeric($logger_factory)) {
            $max_age = $logger_factory;
        }
        @trigger_error('The logger.factory service should be passed to ' . __METHOD__ . '() since drupal:9.3.0 and is required in drupal:10.0.0. See https://www.drupal.org/node/3186186', E_USER_DEPRECATED);
        $logger_factory = \Drupal::service('logger.factory');
    }
    $this->maxAge = $max_age;
    $this->keyValue = $key_value_factory->get('media');
    $this->logger = $logger_factory->get('media');
}

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