public function ImageToolkitForm::buildForm

Implements \Drupal\Core\Form\FormInterface::buildForm().

Overrides SystemConfigFormBase::buildForm

File

drupal/core/modules/system/lib/Drupal/system/Form/ImageToolkitForm.php, line 67
Contains \Drupal\system\Form\ImageToolkitForm.

Class

ImageToolkitForm
Configures image toolkit settings for this site.

Namespace

Drupal\system\Form

Code

public function buildForm(array $form, array &$form_state) {
  $current_toolkit = $this->configFactory
    ->get('system.image')
    ->get('toolkit');
  $form['image_toolkit'] = array(
    '#type' => 'radios',
    '#title' => t('Select an image processing toolkit'),
    '#default_value' => $current_toolkit,
    '#options' => array(),
  );

  // If we have available toolkits, allow the user to select the image toolkit
  // to use and load the settings forms.
  foreach ($this->availableToolkits as $id => $toolkit) {
    $definition = $toolkit
      ->getPluginDefinition();
    $form['image_toolkit']['#options'][$id] = $definition['title'];
    $form['image_toolkit_settings'][$id] = array(
      '#type' => 'fieldset',
      '#title' => t('@toolkit settings', array(
        '@toolkit' => $definition['title'],
      )),
      '#collapsible' => TRUE,
      '#collapsed' => $id == $current_toolkit ? FALSE : TRUE,
      '#tree' => TRUE,
    );
    $form['image_toolkit_settings'][$id] += $toolkit
      ->settingsForm();
  }
  return parent::buildForm($form, $form_state);
}