You are here

public function UpdateFetcher::buildFetchUrl in Drupal 8

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

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.

Overrides UpdateFetcherInterface::buildFetchUrl

See also

\Drupal\update\UpdateProcessor::fetchData()

\Drupal\update\UpdateProcessor::processFetchTask()

\Drupal\update\UpdateManager::getProjects()

1 call to UpdateFetcher::buildFetchUrl()
UpdateFetcher::fetchProjectData in core/modules/update/src/UpdateFetcher.php
Retrieves the project information.

File

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

Class

UpdateFetcher
Fetches project information from remote locations.

Namespace

Drupal\update

Code

public function buildFetchUrl(array $project, $site_key = '') {
  $name = $project['name'];
  $url = $this
    ->getFetchBaseUrl($project);
  $url .= '/' . $name . '/current';

  // Only append usage information if we have a site key and the project is
  // enabled. We do not want to record usage statistics for disabled projects.
  if (!empty($site_key) && strpos($project['project_type'], 'disabled') === FALSE) {

    // Append the site key.
    $url .= strpos($url, '?') !== FALSE ? '&' : '?';
    $url .= 'site_key=';
    $url .= rawurlencode($site_key);

    // Append the version.
    if (!empty($project['info']['version'])) {
      $url .= '&version=';
      $url .= rawurlencode($project['info']['version']);
    }

    // Append the list of modules or themes enabled.
    $list = array_keys($project['includes']);
    $url .= '&list=';
    $url .= rawurlencode(implode(',', $list));
  }
  return $url;
}