protected function ProjectCollector::collateExtensionsIntoProjects in Upgrade Rector 8
Finds topmost extension for each extension and keeps only that.
Parameters
\Drupal\Core\Extension\Extension[] $extensions: List of all enabled extensions in a category.
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 156
Class
- ProjectCollector
- Collects projects collated for the purposes of upgrade rector.
Namespace
Drupal\upgrade_rectorCode
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_rector_test_') === 0) {
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) {
unset($extensions[$name_b]);
}
}
}
return $extensions;
}