function drupal_verify_profile

Same name in other branches
  1. 7.x includes/install.inc \drupal_verify_profile()
  2. 9 core/includes/install.inc \drupal_verify_profile()
  3. 8.9.x core/includes/install.inc \drupal_verify_profile()
  4. 11.x core/includes/install.inc \drupal_verify_profile()

Verifies that all dependencies are met for a given installation profile.

@todo https://www.drupal.org/i/3005959 Rework this method as it is not only about profiles.

Parameters

$install_state: An array of information about the current installation state.

Return value

array The list of modules to install.

2 calls to drupal_verify_profile()
InstallerDependenciesResolutionTest::testDependenciesResolution in core/modules/system/tests/src/Kernel/Installer/InstallerDependenciesResolutionTest.php
Verifies that the exception message in the profile step is correct.
install_verify_requirements in core/includes/install.core.inc
Verifies the requirements for installing Drupal.

File

core/includes/install.inc, line 452

Code

function drupal_verify_profile($install_state) {
    $profile = $install_state['parameters']['profile'];
    if ($profile === FALSE) {
        return [];
    }
    $info = $install_state['profile_info'];
    // Get the list of available modules for the selected installation profile.
    $listing = new ExtensionDiscovery(\Drupal::root());
    $present_modules = [];
    foreach ($listing->scan('module') as $present_module) {
        $present_modules[] = $present_module->getName();
    }
    // The installation profile is also a module, which needs to be installed
    // after all the other dependencies have been installed.
    $present_modules[] = $profile;
    // Verify that all of the profile's required modules are present.
    $missing_modules = array_diff($info['install'], $present_modules);
    $requirements = [];
    if ($missing_modules) {
        $build = [
            '#theme' => 'item_list',
            '#context' => [
                'list_style' => 'comma-list',
            ],
        ];
        foreach ($missing_modules as $module) {
            $build['#items'][] = [
                '#markup' => '<span class="admin-missing">' . Unicode::ucfirst($module) . '</span>',
            ];
        }
        $modules_list = \Drupal::service('renderer')->renderInIsolation($build);
        $requirements['required_modules'] = [
            'title' => t('Required modules'),
            'value' => t('Required modules not found.'),
            'severity' => REQUIREMENT_ERROR,
            'description' => t('The following modules are required but were not found. Move them into the appropriate modules subdirectory, such as <em>/modules</em>. Missing modules: @modules', [
                '@modules' => $modules_list,
            ]),
        ];
    }
    return $requirements;
}

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