You are here

function drupal_required_modules in Drupal 9

Same name and namespace in other branches
  1. 8 core/includes/module.inc \drupal_required_modules()
  2. 6 includes/module.inc \drupal_required_modules()
  3. 7 includes/module.inc \drupal_required_modules()

Returns an array of modules required by core.

1 call to drupal_required_modules()
install_profile_info in core/includes/install.inc
Retrieves information about an installation profile from its .info.yml file.

File

core/includes/module.inc, line 78
API for loading and interacting with Drupal modules.

Code

function drupal_required_modules() {
  $listing = new ExtensionDiscovery(\Drupal::root());
  $files = $listing
    ->scan('module');
  $required = [];

  // Unless called by the installer, an installation profile is required and
  // must always be loaded.
  if ($profile = \Drupal::installProfile()) {
    $required[] = $profile;
  }
  foreach ($files as $name => $file) {
    $info = \Drupal::service('info_parser')
      ->parse($file
      ->getPathname());
    if (!empty($info) && !empty($info['required']) && $info['required']) {
      $required[] = $name;
    }
  }
  return $required;
}