SelectProfileForm.php in Zircon Profile 8.0
File
core/lib/Drupal/Core/Installer/Form/SelectProfileForm.php
View source
<?php
namespace Drupal\Core\Installer\Form;
use Drupal\Core\Form\FormBase;
use Drupal\Core\Form\FormStateInterface;
class SelectProfileForm extends FormBase {
public function getFormId() {
return 'install_select_profile_form';
}
public function buildForm(array $form, FormStateInterface $form_state, $install_state = NULL) {
$form['#title'] = $this
->t('Select an installation profile');
$profiles = array();
$names = array();
foreach ($install_state['profiles'] as $profile) {
$details = install_profile_info($profile
->getName());
if ($details['hidden'] === TRUE && !drupal_valid_test_ua()) {
continue;
}
$profiles[$profile
->getName()] = $details;
$name = isset($details['name']) ? $details['name'] : $profile
->getName();
$names[$profile
->getName()] = $name;
}
natcasesort($names);
if (isset($names['minimal'])) {
$names = array(
'minimal' => $names['minimal'],
) + $names;
}
if (isset($names['standard'])) {
$names = array(
'standard' => $names['standard'],
) + $names;
}
$form['profile'] = array(
'#type' => 'radios',
'#title' => $this
->t('Select an installation profile'),
'#title_display' => 'invisible',
'#options' => array_map(array(
$this,
't',
), $names),
'#default_value' => 'standard',
);
foreach (array_keys($names) as $profile_name) {
$form['profile'][$profile_name]['#description'] = isset($profiles[$profile_name]['description']) ? $this
->t($profiles[$profile_name]['description']) : '';
}
$form['actions'] = array(
'#type' => 'actions',
);
$form['actions']['submit'] = array(
'#type' => 'submit',
'#value' => $this
->t('Save and continue'),
'#button_type' => 'primary',
);
return $form;
}
public function submitForm(array &$form, FormStateInterface $form_state) {
global $install_state;
$install_state['parameters']['profile'] = $form_state
->getValue('profile');
}
}