public function UpdateManager::getProjects in Drupal 8
Same name and namespace in other branches
- 9 core/modules/update/src/UpdateManager.php \Drupal\update\UpdateManager::getProjects()
- 10 core/modules/update/src/UpdateManager.php \Drupal\update\UpdateManager::getProjects()
Fetches an array of installed and enabled projects.
This is only responsible for generating an array of projects (taking into account projects that include more than one module or theme). Other information like the specific version and install type (official release, dev snapshot, etc) is handled later in update_process_project_info() since that logic is only required when preparing the status report, not for fetching the available release data.
This array is fairly expensive to construct, since it involves a lot of disk I/O, so we store the results. However, since this is not the data about available updates fetched from the network, it is acceptable to invalidate it somewhat quickly. If we keep this data for very long, site administrators are more likely to see incorrect results if they upgrade to a newer version of a module or theme but do not visit certain pages that automatically clear this data.
Return value
array An associative array of currently enabled projects keyed by the machine-readable project short name. Each project contains:
- name: The machine-readable project short name.
- info: An array with values from the main .info.yml file for this
project.
- name: The human-readable name of the project.
- package: The package that the project is grouped under.
- version: The version of the project.
- project: The Drupal.org project name.
- datestamp: The date stamp of the project's main .info.yml file.
- _info_file_ctime: The maximum file change time for all of the .info.yml files included in this project.
- datestamp: The date stamp when the project was released, if known.
- includes: An associative array containing all projects included with this project, keyed by the machine-readable short name with the human-readable name as value.
- project_type: The type of project. Allowed values are 'module' and 'theme'.
- project_status: This indicates if the project is enabled and will always be TRUE, as the function only returns enabled projects.
Overrides UpdateManagerInterface::getProjects
See also
update_calculate_project_data()
\Drupal\update\UpdateManager::projectStorage()
1 call to UpdateManager::getProjects()
- UpdateManager::refreshUpdateData in core/
modules/ update/ src/ UpdateManager.php - Clears out all the available update data and initiates re-fetching.
File
- core/
modules/ update/ src/ UpdateManager.php, line 142
Class
- UpdateManager
- Default implementation of UpdateManagerInterface.
Namespace
Drupal\updateCode
public function getProjects() {
if (empty($this->projects)) {
// Retrieve the projects from storage, if present.
$this->projects = $this
->projectStorage('update_project_projects');
if (empty($this->projects)) {
// Still empty, so we have to rebuild.
$module_data = $this->moduleExtensionList
->reset()
->getList();
$theme_data = $this->themeHandler
->rebuildThemeData();
$project_info = new ProjectInfo();
$project_info
->processInfoList($this->projects, $module_data, 'module', TRUE);
$project_info
->processInfoList($this->projects, $theme_data, 'theme', TRUE);
if ($this->updateSettings
->get('check.disabled_extensions')) {
$project_info
->processInfoList($this->projects, $module_data, 'module', FALSE);
$project_info
->processInfoList($this->projects, $theme_data, 'theme', FALSE);
}
// Allow other modules to alter projects before fetching and comparing.
$this->moduleHandler
->alter('update_projects', $this->projects);
// Store the site's project data for at most 1 hour.
$this->keyValueStore
->setWithExpire('update_project_projects', $this->projects, 3600);
}
}
return $this->projects;
}