You are here

protected function ModuleExtensionList::doList in Drupal 10

Same name and namespace in other branches
  1. 8 core/lib/Drupal/Core/Extension/ModuleExtensionList.php \Drupal\Core\Extension\ModuleExtensionList::doList()
  2. 9 core/lib/Drupal/Core/Extension/ModuleExtensionList.php \Drupal\Core\Extension\ModuleExtensionList::doList()

File

core/lib/Drupal/Core/Extension/ModuleExtensionList.php, line 153

Class

ModuleExtensionList
Provides a list of available modules.

Namespace

Drupal\Core\Extension

Code

protected function doList() {

  // Find modules.
  $extensions = parent::doList();

  // It is possible that a module was marked as required by
  // hook_system_info_alter() and modules that it depends on are not required.
  foreach ($extensions as $extension) {
    $this
      ->ensureRequiredDependencies($extension, $extensions);
  }

  // Add status, weight, and schema version.
  $installed_modules = $this->configFactory
    ->get('core.extension')
    ->get('module') ?: [];
  foreach ($extensions as $name => $module) {
    $module->weight = $installed_modules[$name] ?? 0;
    $module->status = (int) isset($installed_modules[$name]);
    $module->schema_version = UpdateHookRegistry::SCHEMA_UNINSTALLED;
  }
  $extensions = $this->moduleHandler
    ->buildModuleDependencies($extensions);
  if ($this->installProfile && $extensions[$this->installProfile]) {
    $active_profile = $extensions[$this->installProfile];

    // Installation profile hooks are always executed last.
    $active_profile->weight = 1000;

    // Installation profiles are hidden by default, unless explicitly
    // specified otherwise in the .info.yml file.
    if (!isset($active_profile->info['hidden'])) {
      $active_profile->info['hidden'] = TRUE;
    }

    // The installation profile is required.
    $active_profile->info['required'] = TRUE;

    // Add a default distribution name if the profile did not provide one.
    // @see install_profile_info()
    // @see drupal_install_profile_distribution_name()
    if (!isset($active_profile->info['distribution']['name'])) {
      $active_profile->info['distribution']['name'] = 'Drupal';
    }
  }
  return $extensions;
}