public SelectProfileForm::buildForm(array $form, FormStateInterface $form_state, $install_state = NULL)
Form constructor.
Parameters
array $form: An associative array containing the structure of the form.
\Drupal\Core\Form\FormStateInterface $form_state: The current state of the form.
Return value
array The form structure.
Overrides FormInterface::buildForm
File
- core/lib/Drupal/Core/Installer/Form/SelectProfileForm.php, line 23
Class
- SelectProfileForm
- Provides the profile selection form.
Namespace
Drupal\Core\Installer\Form
Code
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 | 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 ) { /** @var $profile \Drupal\Core\Extension\Extension */ $details = install_profile_info( $profile ->getName()); // Don't show hidden profiles. This is used by to hide the testing profile, // which only exists to speed up test runs. if ( $details [ 'hidden' ] === TRUE && !drupal_valid_test_ua()) { continue ; } $profiles [ $profile ->getName()] = $details ; // Determine the name of the profile; default to file name if defined name // is unspecified. $name = isset( $details [ 'name' ]) ? $details [ 'name' ] : $profile ->getName(); $names [ $profile ->getName()] = $name ; } // Display radio buttons alphabetically by human-readable name, but always // put the core profiles first (if they are present in the filesystem). natcasesort( $names ); if (isset( $names [ 'minimal' ])) { // If the expert ("Minimal") core profile is present, put it in front of // any non-core profiles rather than including it with them alphabetically, // since the other profiles might be intended to group together in a // particular way. $names = array ( 'minimal' => $names [ 'minimal' ]) + $names ; } if (isset( $names [ 'standard' ])) { // If the default ("Standard") core profile is present, put it at the very // top of the list. This profile will have its radio button pre-selected, // so we want it to always appear at the top. $names = array ( 'standard' => $names [ 'standard' ]) + $names ; } // The profile name and description are extracted for translation from the // .info file, so we can use $this->t() on them even though they are dynamic // data at this point. $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 ; } |
Please login to continue.