protected function ProjectCollector::collateExtensionsIntoProjects in Upgrade Status 8.3
Same name and namespace in other branches
- 8.2 src/ProjectCollector.php \Drupal\upgrade_status\ProjectCollector::collateExtensionsIntoProjects()
Finds topmost extension for each extension and keeps only that.
Parameters
\Drupal\Core\Extension\Extension[] $extensions: List of all enabled extensions.
Return value
\Drupal\Core\Extension\Extension[] List of extensions, with only the topmost extension left for each extension that has a parent extension.
1 call to ProjectCollector::collateExtensionsIntoProjects()
- ProjectCollector::collectProjects in src/
ProjectCollector.php - Collect projects of installed modules grouped by custom and contrib.
File
- src/
ProjectCollector.php, line 371
Class
- ProjectCollector
- Collects projects and their associated metadata collated for Upgrade Status.
Namespace
Drupal\upgrade_statusCode
protected function collateExtensionsIntoProjects(array $extensions) {
foreach ($extensions as $name_a => $extension_a) {
$path_a = $extension_a
->getPath() . '/';
$path_a_length = strlen($path_a);
foreach ($extensions as $name_b => $extension_b) {
// Skip collation for test modules except where we test that.
if (strpos($name_b, 'upgrade_status_test_') === 0 && $name_b != 'upgrade_status_test_submodules_a' && $name_b != 'upgrade_status_test_submodules_with_errors_a') {
continue;
}
$path_b = $extension_b
->getPath();
// If the extension is not the same but the beginning of paths match,
// remove this extension from the list as it is part of another one.
if ($name_b != $name_a && substr($path_b, 0, $path_a_length) === $path_a) {
// If the existing project was already Drupal 9 compatible, consider
// this subcomponent as well. If this component was enabled, it would
// affect how we consider the Drupal 9 compatibility.
if (!empty($extensions[$name_a]->info['upgrade_status_next_major_compatible']) && !empty($extension_b->status)) {
// Overwrite compatibility. If this is still compatible, it will
// keep being TRUE, otherwise FALSE.
$extensions[$name_a]->info['upgrade_status_next_major_compatible'] = isset($extension_b->info['core_version_requirement']) && self::isCompatibleWithNextMajorDrupal($extension_b->info['core_version_requirement']);
}
// Remove the subextension.
unset($extensions[$name_b]);
}
}
}
return $extensions;
}