You are here

protected function ProjectCollector::collateCustomExtensionsIntoProjects in Upgrade Status 8

Finds topmost custom extension for each extension and keeps only that.

Parameters

\Drupal\Core\Extension\Extension[] $projects: List of all enabled custom extensions.

Return value

\Drupal\Core\Extension\Extension[] List of custom extensions, with only the topmost custom extension left for each extension that has a parent extension.

1 call to ProjectCollector::collateCustomExtensionsIntoProjects()
ProjectCollector::collectProjects in src/ProjectCollector.php
Collect projects of installed modules grouped by custom and contrib.

File

src/ProjectCollector.php, line 138

Class

ProjectCollector
Collects projects collated for the purposes of upgrade status.

Namespace

Drupal\upgrade_status

Code

protected function collateCustomExtensionsIntoProjects(array $projects) {
  foreach ($projects as $name_a => $data_a) {
    $subpath_a = $data_a->subpath . '/';
    $subpath_a_length = strlen($subpath_a);
    foreach ($projects as $name_b => $data_b) {
      $subpath_b = $data_b->subpath;

      // 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($subpath_b, 0, $subpath_a_length) === $subpath_a) {
        unset($projects[$name_b]);
      }
    }
  }
  return $projects;
}