class UpdateFetcher implements UpdateFetcherInterface (View source)

Fetches project information from remote locations.

Traits

Provides dependency injection friendly methods for serialization.

Constants

UPDATE_DEFAULT_URL

URL to check for updates, if a given project doesn't define its own.

Properties

protected array $_serviceIds

An array of service IDs keyed by property name used for serialization.

from  DependencySerializationTrait
protected array $_entityStorages

An array of entity type IDs keyed by the property name of their storages.

from  DependencySerializationTrait
protected string $fetchUrl

The fetch url configured in the update settings.

protected Config $updateSettings

The update settings

protected ClientInterface $httpClient

The HTTP client to fetch the feed data with.

Methods

__sleep()

{@inheritdoc}

__wakeup()

{@inheritdoc}

__construct(ConfigFactoryInterface $config_factory, ClientInterface $http_client)

Constructs a UpdateFetcher.

string
fetchProjectData(array $project, string $site_key = '')

Retrieves the project information.

string
buildFetchUrl(array $project, string $site_key = '')

Generates the URL to fetch information about project updates.

string
getFetchBaseUrl(array $project)

Returns the base of the URL to fetch available update data for a project.

Details

__sleep()

{@inheritdoc}

__wakeup()

{@inheritdoc}

__construct(ConfigFactoryInterface $config_factory, ClientInterface $http_client)

Constructs a UpdateFetcher.

Parameters

ConfigFactoryInterface $config_factory

The config factory.

ClientInterface $http_client

A Guzzle client object.

string fetchProjectData(array $project, string $site_key = '')

Retrieves the project information.

Parameters

array $project

The array of project information from \Drupal\update\UpdateManager::getProjects().

string $site_key

(optional) The anonymous site key hash. Defaults to an empty string.

Return Value

string

The project information fetched as string. Empty string upon failure.

string buildFetchUrl(array $project, string $site_key = '')

Generates the URL to fetch information about project updates.

This figures out the right URL to use, based on the project's .info.yml file and the global defaults. Appends optional query arguments when the site is configured to report usage stats.

Parameters

array $project

The array of project information from \Drupal\update\UpdateManager::getProjects().

string $site_key

(optional) The anonymous site key hash. Defaults to an empty string.

Return Value

string

The URL for fetching information about updates to the specified project.

string getFetchBaseUrl(array $project)

Returns the base of the URL to fetch available update data for a project.

Parameters

array $project

The array of project information from \Drupal\update\UpdateManager::getProjects().

Return Value

string

The base of the URL used for fetching available update data. This does not include the path elements to specify a particular project, version, site_key, etc.