You are here

public function UpdateFetcher::__construct in Drupal 9

Same name and namespace in other branches
  1. 8 core/modules/update/src/UpdateFetcher.php \Drupal\update\UpdateFetcher::__construct()

Constructs an UpdateFetcher.

Parameters

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

\GuzzleHttp\ClientInterface $http_client: A Guzzle client object.

\Drupal\Core\Site\Settings|null $settings: The settings instance.

File

core/modules/update/src/UpdateFetcher.php, line 61

Class

UpdateFetcher
Fetches project information from remote locations.

Namespace

Drupal\update

Code

public function __construct(ConfigFactoryInterface $config_factory, ClientInterface $http_client, Settings $settings = NULL) {
  $this->fetchUrl = $config_factory
    ->get('update.settings')
    ->get('fetch.url');
  $this->httpClient = $http_client;
  $this->updateSettings = $config_factory
    ->get('update.settings');
  if (is_null($settings)) {
    @trigger_error('The settings service should be passed to UpdateFetcher::__construct() since 9.1.0. This will be required in Drupal 10.0.0. See https://www.drupal.org/node/3179315', E_USER_DEPRECATED);
    $settings = \Drupal::service('settings');
  }
  $this->withHttpFallback = $settings
    ->get('update_fetch_with_http_fallback', FALSE);
}