drupal_verify_profile

drupal_verify_profile($install_state)

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.

File

core/includes/install.inc, line 557
API functions for installing modules and themes.

Code

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
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 = array();
  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['dependencies'], $present_modules);
 
  $requirements = array();
 
  if ($missing_modules) {
    $build = [
      '#theme' => 'item_list',
      '#context' => ['list_style' => 'comma-list'],
    ];
 
    foreach ($missing_modules as $module) {
      $build['#items'][] = array('#markup' => '<span class="admin-missing">' . Unicode::ucfirst($module) . '</span>');
    }
 
    $modules_list = \Drupal::service('renderer')->renderPlain($build);
    $requirements['required_modules'] = array(
      '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', array('@modules' => $modules_list)),
    );
  }
  return $requirements;
}
doc_Drupal
2025-01-10 15:47:30
Comments
Leave a Comment

Please login to continue.