function UpdateFetcher::buildFetchUrl

Same name and namespace in other branches
  1. 11.x core/modules/update/src/UpdateFetcher.php \Drupal\update\UpdateFetcher::buildFetchUrl()
  2. 10 core/modules/update/src/UpdateFetcher.php \Drupal\update\UpdateFetcher::buildFetchUrl()
  3. 8.9.x core/modules/update/src/UpdateFetcher.php \Drupal\update\UpdateFetcher::buildFetchUrl()

File

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

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;
}

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