You are here

function drupal_check_profile in Drupal 9

Same name and namespace in other branches
  1. 8 core/includes/install.inc \drupal_check_profile()
  2. 5 includes/install.inc \drupal_check_profile()
  3. 6 includes/install.inc \drupal_check_profile()
  4. 7 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.

1 call to drupal_check_profile()
install_check_requirements in core/includes/install.core.inc
Checks installation requirements and reports any errors.

File

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