function InstallerKernel::installGetProfile
Gets the profile to be installed.
Return value
string|null|\Drupal\Core\Extension\Extension Returns NULL if no profile was selected or FALSE if the site has no profile, or the profile extension object with the profile info added.
See also
1 call to InstallerKernel::installGetProfile()
- InstallerKernel::getExtensions in core/
lib/ Drupal/ Core/ Installer/ InstallerKernel.php - Get the core.extension config object.
File
-
core/
lib/ Drupal/ Core/ Installer/ InstallerKernel.php, line 177
Class
- InstallerKernel
- Extend DrupalKernel to handle force some kernel behaviors.
Namespace
Drupal\Core\InstallerCode
private function installGetProfile() : null|false|Extension {
global $install_state;
$profile = NULL;
if (empty($install_state['profiles'])) {
throw new \RuntimeException('No profiles found.');
}
// If there is only one profile available it will always be the one
// selected.
if (count($install_state['profiles']) == 1) {
$profile = reset($install_state['profiles']);
}
// If a valid profile has already been selected, return the selection.
if (array_key_exists('profile', $install_state['parameters'])) {
$profile = $install_state['parameters']['profile'];
if ($profile && isset($install_state['profiles'][$profile])) {
$profile = $install_state['profiles'][$profile];
}
}
// Not using a profile.
if ($profile === FALSE) {
return $profile;
}
$info_parser = new InfoParser($this->root);
if ($profile instanceof Extension) {
$profile->info = $info_parser->parse($profile->getPathname());
return $profile;
}
$visible_profiles = [];
// If any of the profiles are distribution profiles, select the first one.
foreach ($install_state['profiles'] as $profile) {
$profile->info = $info_parser->parse($profile->getPathname());
if (!empty($profile->info['distribution'])) {
return $profile;
}
if (!isset($profile->info['hidden']) || !$profile->info['hidden']) {
$visible_profiles[] = $profile;
}
}
// If there is only one visible profile, select it.
if (count($visible_profiles) == 1) {
return $visible_profiles[0];
}
return NULL;
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.