function _install_select_profile
Same name in other branches
- 7.x includes/install.core.inc \_install_select_profile()
- 9 core/includes/install.core.inc \_install_select_profile()
- 10 core/includes/install.core.inc \_install_select_profile()
- 11.x core/includes/install.core.inc \_install_select_profile()
Determines the installation profile to use in the installer.
Depending on the context from which it's being called, this method may be used to:
- Automatically select a profile under certain conditions.
- Indicate which profile has already been selected.
- Indicate that a profile still needs to be selected.
A profile will be selected automatically if one of the following conditions is met. They are checked in the given order:
- Only one profile is available.
- A specific profile name is requested in installation parameters:
- For interactive installations via request query parameters.
- For non-interactive installations via install_drupal() settings.
- One of the available profiles is a distribution. If multiple profiles are distributions, then the first discovered profile will be selected.
- Only one visible profile is available.
Parameters
array $install_state: The current installer state, containing a 'profiles' key, which is an associative array of profiles with the machine-readable names as keys.
Return value
string|null The machine-readable name of the selected profile or NULL if no profile was selected.
@see install_select_profile()
2 calls to _install_select_profile()
- install_begin_request in core/
includes/ install.core.inc - Begins an installation request, modifying the installation state as needed.
- install_select_profile in core/
includes/ install.core.inc - Selects which profile to install.
File
-
core/
includes/ install.core.inc, line 1283
Code
function _install_select_profile(&$install_state) {
// If there is only one profile available it will always be the one selected.
if (count($install_state['profiles']) == 1) {
return key($install_state['profiles']);
}
// If a valid profile has already been selected, return the selection.
if (!empty($install_state['parameters']['profile'])) {
$profile = $install_state['parameters']['profile'];
if (isset($install_state['profiles'][$profile])) {
return $profile;
}
}
// If any of the profiles are distribution profiles, return the first one.
foreach ($install_state['profiles'] as $profile) {
$profile_info = install_profile_info($profile->getName());
if (!empty($profile_info['distribution'])) {
return $profile->getName();
}
}
// Get all visible (not hidden) profiles.
$visible_profiles = array_filter($install_state['profiles'], function ($profile) {
$profile_info = install_profile_info($profile->getName());
return !isset($profile_info['hidden']) || !$profile_info['hidden'];
});
// If there is only one visible profile, return it.
if (count($visible_profiles) == 1) {
return key($visible_profiles);
}
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.