function drupal_required_modules

Same name in other branches
  1. 7.x includes/module.inc \drupal_required_modules()
  2. 8.9.x core/includes/module.inc \drupal_required_modules()

Returns an array of modules required by core.

Deprecated

in drupal:9.4.0 and is removed from drupal:10.0.0. There's no replacement.

See also

https://www.drupal.org/node/3262811

1 call to drupal_required_modules()
ModuleLegacyTest::testDrupalRequiredModules in core/tests/Drupal/KernelTests/Core/Extension/ModuleLegacyTest.php
Test deprecation of drupal_required_modules() function.

File

core/includes/module.inc, line 102

Code

function drupal_required_modules() {
    @trigger_error(__FUNCTION__ . "() is deprecated in drupal:9.4.0 and is removed from drupal:10.0.0. There's no replacement. See https://www.drupal.org/node/3262811", E_USER_DEPRECATED);
    $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;
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.