1 install.core.inc | _install_select_profile($profiles) |
Selects an installation profile from a list or from a $_POST submission.
Return value
string|NULL: The selected profile from $_POST, or the automatically selected profile if possible to determine one without prompting the user. If no profile can be selected, NULL is returned.
Throws
Exception
File
- core/
includes/ install.core.inc, line 1160 - API functions for installing Backdrop.
Code
function _install_select_profile($profiles) {
if (sizeof($profiles) == 0) {
throw new Exception(install_no_profile_error());
}
// Don't need to choose profile if only one available.
if (sizeof($profiles) == 1) {
$profile = array_pop($profiles);
return $profile->name;
}
else {
$available_profiles = array();
$exclusive_profiles = array();
foreach ($profiles as $profile) {
if (!empty($_POST['profile']) && ($_POST['profile'] == $profile->name)) {
return $profile->name;
}
$profile_info = install_profile_info($profile->name);
// Check for profiles marked as "hidden".
if (empty($profile_info['hidden'])) {
$available_profiles[] = $profile->name;
}
// Check for a profile marked as "exclusive".
if (!empty($profile_info['exclusive'])) {
$exclusive_profiles[] = $profile->name;
}
}
// If there is only one available profile, return it.
if (count($available_profiles) == 1) {
return reset($available_profiles);
}
// If there is only one exclusive profile, return it.
elseif (count($exclusive_profiles) == 1) {
return reset($exclusive_profiles);
}
}
// No profile yet selected or possible to select automatically.
return NULL;
}