function LocaleProjectStorage::getProjects
Get array of projects which are available for interface translation.
This project data contains all projects which will be checked for available interface translations.
For full functionality this function depends on the Update Status module. When the Update Status module is enabled the project data will contain the most recent module status; both in enabled status as in version. When the Update Status module is disabled this function will return the last known module state. The status will only be updated once the Update Status module is enabled.
Parameters
array $project_names: Array of names of the projects to get.
Return value
array Array of project data for translation update.
Overrides LocaleProjectStorageInterface::getProjects
File
-
core/
modules/ locale/ src/ LocaleProjectStorage.php, line 201
Class
- LocaleProjectStorage
- Provides the locale project storage system using a key value store.
Namespace
Drupal\localeCode
public function getProjects(array $project_names = []) : array {
if (empty($this->projectCache)) {
// Get project data from the database.
$row_count = $this->countProjects();
// https://www.drupal.org/node/1777106 is a follow-up issue to make the
// check for possible out-of-date project information more robust.
if ($row_count == 0) {
\Drupal::moduleHandler()->loadInclude('locale', 'inc', 'locale.compare');
// At least the core project should be in the database, so we build the
// data if none are found.
locale_translation_build_projects();
}
$this->projectCache = $this->getAll();
array_walk($this->projectCache, function (&$project) {
$project = (object) $project;
});
}
// Return the requested project names or all projects.
if ($project_names) {
return array_intersect_key($this->projectCache, array_combine($project_names, $project_names));
}
return $this->projectCache;
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.