Same name and namespace in other branches
  1. 5.x includes/install.inc \drupal_check_profile()
  2. 6.x includes/install.inc \drupal_check_profile()
  3. 7.x includes/install.inc \drupal_check_profile()
  4. 8.9.x core/includes/install.inc \drupal_check_profile()
  5. 9 core/includes/install.inc \drupal_check_profile()

Checks an installation profile's requirements.

Parameters

string $profile: Name of installation profile to check.

Return value

array Array of the installation profile's requirements.

File

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

Code

function drupal_check_profile($profile) {
  $info = install_profile_info($profile);

  // Collect requirement testing results.
  $requirements = [];

  // Performs an ExtensionDiscovery scan as the system module is unavailable and
  // we don't yet know where all the modules are located.
  // @todo Remove as part of https://www.drupal.org/node/2186491
  $drupal_root = \Drupal::root();
  $module_list = (new ExtensionDiscovery($drupal_root))
    ->scan('module');
  foreach ($info['install'] as $module) {

    // If the module is in the module list we know it exists and we can continue
    // including and registering it.
    // @see \Drupal\Core\Extension\ExtensionDiscovery::scanDirectory()
    if (isset($module_list[$module])) {
      $function = $module . '_requirements';
      $module_path = $module_list[$module]
        ->getPath();
      $install_file = "{$drupal_root}/{$module_path}/{$module}.install";
      if (is_file($install_file)) {
        require_once $install_file;
      }
      \Drupal::service('class_loader')
        ->addPsr4('Drupal\\' . $module . '\\', \Drupal::root() . "/{$module_path}/src");
      if (function_exists($function)) {
        $requirements = array_merge($requirements, $function('install'));
      }
    }
  }

  // Add the profile requirements.
  $function = $profile . '_requirements';
  if (function_exists($function)) {
    $requirements = array_merge($requirements, $function('install'));
  }
  return $requirements;
}