You are here

function drupal_verify_profile in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 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.

1 call to drupal_verify_profile()
install_verify_requirements in core/includes/install.core.inc
Verifies the requirements for installing Drupal.

File

core/includes/install.inc, line 554
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 = 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;
}