You are here

public function ImageToolkitForm::buildForm in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 core/modules/system/src/Form/ImageToolkitForm.php \Drupal\system\Form\ImageToolkitForm::buildForm()

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 ConfigFormBase::buildForm

File

core/modules/system/src/Form/ImageToolkitForm.php, line 71
Contains \Drupal\system\Form\ImageToolkitForm.

Class

ImageToolkitForm
Configures image toolkit settings for this site.

Namespace

Drupal\system\Form

Code

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

  // If we have more than one image toolkit, allow the user to select the one
  // to use, and load each of the toolkits' settings form.
  foreach ($this->availableToolkits as $id => $toolkit) {
    $definition = $toolkit
      ->getPluginDefinition();
    $form['image_toolkit']['#options'][$id] = $definition['title'];
    $form['image_toolkit_settings'][$id] = array(
      '#type' => 'details',
      '#title' => $this
        ->t('@toolkit settings', array(
        '@toolkit' => $definition['title'],
      )),
      '#open' => TRUE,
      '#tree' => TRUE,
      '#states' => array(
        'visible' => array(
          ':radio[name="image_toolkit"]' => array(
            'value' => $id,
          ),
        ),
      ),
    );
    $form['image_toolkit_settings'][$id] += $toolkit
      ->buildConfigurationForm(array(), $form_state);
  }
  return parent::buildForm($form, $form_state);
}