You are here

protected function InstallCommand::getProfiles in Drupal 10

Same name and namespace in other branches
  1. 8 core/lib/Drupal/Core/Command/InstallCommand.php \Drupal\Core\Command\InstallCommand::getProfiles()
  2. 9 core/lib/Drupal/Core/Command/InstallCommand.php \Drupal\Core\Command\InstallCommand::getProfiles()

Gets a list of profiles.

Parameters

bool $include_hidden: (optional) Whether to include hidden profiles. Defaults to FALSE.

bool $auto_select_distributions: (optional) Whether to only return the first distribution found.

Return value

string[] An array of profile descriptions keyed by the profile machine name.

File

core/lib/Drupal/Core/Command/InstallCommand.php, line 318

Class

InstallCommand
Installs a Drupal site for local testing/development.

Namespace

Drupal\Core\Command

Code

protected function getProfiles($include_hidden = FALSE, $auto_select_distributions = TRUE) {

  // Build a list of all available profiles.
  $listing = new ExtensionDiscovery(getcwd(), FALSE);
  $listing
    ->setProfileDirectories([]);
  $profiles = [];
  $info_parser = new InfoParserDynamic(getcwd());
  foreach ($listing
    ->scan('profile') as $profile) {
    $details = $info_parser
      ->parse($profile
      ->getPathname());

    // Don't show hidden profiles.
    if (!$include_hidden && !empty($details['hidden'])) {
      continue;
    }

    // Determine the name of the profile; default to the internal name if none
    // is specified.
    $name = $details['name'] ?? $profile
      ->getName();
    $description = $details['description'] ?? $name;
    $profiles[$profile
      ->getName()] = $description;
    if ($auto_select_distributions && !empty($details['distribution'])) {
      return [
        $profile
          ->getName() => $description,
      ];
    }
  }
  return $profiles;
}