public function UpdateManager::projectStorage in Drupal 8
Same name and namespace in other branches
- 9 core/modules/update/src/UpdateManager.php \Drupal\update\UpdateManager::projectStorage()
Retrieves update storage data or empties it.
Two very expensive arrays computed by this module are the list of all installed modules and themes (and .info.yml data, project associations, etc), and the current status of the site relative to the currently available releases. These two arrays are stored and used whenever possible. The data is cleared whenever the administrator visits the status report, available updates report, or the module or theme administration pages, since we should always recompute the most current values on any of those pages.
Note: while both of these arrays are expensive to compute (in terms of disk I/O and some fairly heavy CPU processing), neither of these is the actual data about available updates that we have to fetch over the network from updates.drupal.org. That information is stored in the 'update_available_releases' collection -- it needs to persist longer than 1 hour and never get invalidated just by visiting a page on the site.
Parameters
string $key: The key of data to return. Valid options are 'update_project_data' and 'update_project_projects'.
Return value
array The stored value of the $projects array generated by update_calculate_project_data() or \Drupal\update\UpdateManager::getProjects(), or an empty array when the storage is cleared. array when the storage is cleared.
Overrides UpdateManagerInterface::projectStorage
1 call to UpdateManager::projectStorage()
- UpdateManager::getProjects in core/
modules/ update/ src/ UpdateManager.php - Fetches an array of installed and enabled projects.
File
- core/
modules/ update/ src/ UpdateManager.php, line 169
Class
- UpdateManager
- Default implementation of UpdateManagerInterface.
Namespace
Drupal\updateCode
public function projectStorage($key) {
$projects = [];
// On certain paths, we should clear the data and recompute the projects for
// update status of the site to avoid presenting stale information.
$route_names = [
'update.theme_update',
'system.modules_list',
'system.theme_install',
'update.module_update',
'update.module_install',
'update.status',
'update.report_update',
'update.report_install',
'update.settings',
'system.status',
'update.manual_status',
'update.confirmation_page',
'system.themes_page',
];
if (in_array(\Drupal::routeMatch()
->getRouteName(), $route_names)) {
$this->keyValueStore
->delete($key);
}
else {
$projects = $this->keyValueStore
->get($key, []);
}
return $projects;
}