function drupal_verify_profile in Drupal 9
Same name and namespace in other branches
- 8 core/includes/install.inc \drupal_verify_profile()
- 5 includes/install.inc \drupal_verify_profile()
- 6 includes/install.inc \drupal_verify_profile()
- 7 includes/install.inc \drupal_verify_profile()
- 10 core/includes/install.inc \drupal_verify_profile()
Verifies that all dependencies are met for a given installation profile.
Parameters
$install_state: An array of information about the current installation state.
Return value
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 534 - API functions for installing modules and themes.
Code
function drupal_verify_profile($install_state) {
$profile = $install_state['parameters']['profile'];
$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')
->renderPlain($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;
}