You are here

protected function InstallCommand::getProfiles in Drupal 8

Same name and namespace in other branches
  1. 9 core/lib/Drupal/Core/Command/InstallCommand.php \Drupal\Core\Command\InstallCommand::getProfiles()
  2. 10 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.

2 calls to InstallCommand::getProfiles()
InstallCommand::selectProfile in core/lib/Drupal/Core/Command/InstallCommand.php
Selects the install profile to use.
InstallCommand::validateProfile in core/lib/Drupal/Core/Command/InstallCommand.php
Validates a user provided install profile.

File

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

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 = isset($details['name']) ? $details['name'] : $profile
      ->getName();
    $description = isset($details['description']) ? $details['description'] : $name;
    $profiles[$profile
      ->getName()] = $description;
    if ($auto_select_distributions && !empty($details['distribution'])) {
      return [
        $profile
          ->getName() => $description,
      ];
    }
  }
  return $profiles;
}