function UpdateFetcher::buildFetchUrl

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

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
    // installed. We do not want to record usage statistics for uninstalled
    // projects.
    if (!empty($site_key) && !str_contains($project['project_type'], 'disabled')) {
        // Append the site key.
        $url .= str_contains($url, '?') ? '&' : '?';
        $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 installed.
        $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.