function UpdateCalculator::processProjectInfo
Same name and namespace in other branches
- main core/modules/update/src/UpdateCalculator.php \Drupal\update\UpdateCalculator::processProjectInfo()
Determines version and type information for currently installed projects.
Processes the list of projects on the system to figure out the currently installed versions, and other information that is required before we can compare against the available releases to produce the status report.
Parameters
array $projects: Array of project information from \Drupal\update\UpdateManagerInterface::getProjects().
File
-
core/
modules/ update/ src/ UpdateCalculator.php, line 38
Class
- UpdateCalculator
- Calculate project update data.
Namespace
Drupal\updateCode
public function processProjectInfo(array &$projects) : void {
foreach ($projects as $key => $project) {
// Assume an official release until we see otherwise.
$installType = 'official';
$info = $project['info'];
if (isset($info['version'])) {
// Check for development snapshots.
if (preg_match('@(dev|HEAD)@', $info['version'])) {
$installType = 'dev';
}
// Figure out what the currently installed major version is. We need
// to handle both contribution (e.g. "5.x-1.3", major = 1) and core
// (e.g. "5.1", major = 5) version strings.
$matches = [];
if (preg_match('/^(\\d+\\.x-)?(\\d+)\\..*$/', $info['version'], $matches)) {
$info['major'] = $matches[2];
}
else {
// This would only happen for version strings that don't follow the
// drupal.org convention.
$info['major'] = -1;
}
}
else {
// No version info available at all.
$installType = 'unknown';
$info['version'] = $this->t('Unknown');
$info['major'] = -1;
}
// Finally, save the results we care about into the $projects array.
$projects[$key]['existing_version'] = $info['version'];
$projects[$key]['existing_major'] = $info['major'];
$projects[$key]['install_type'] = $installType;
}
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.