You are here

public function WebformAdminConfigExportersForm::buildForm in Webform 8.5

Same name and namespace in other branches
  1. 6.x src/Form/AdminConfig/WebformAdminConfigExportersForm.php \Drupal\webform\Form\AdminConfig\WebformAdminConfigExportersForm::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

src/Form/AdminConfig/WebformAdminConfigExportersForm.php, line 80

Class

WebformAdminConfigExportersForm
Configure webform admin settings for exporters.

Namespace

Drupal\webform\Form\AdminConfig

Code

public function buildForm(array $form, FormStateInterface $form_state) {
  $config = $this
    ->config('webform.settings');
  $form['export_settings'] = [
    '#type' => 'details',
    '#title' => $this
      ->t('Export general settings'),
    '#open' => TRUE,
  ];
  $form['export_settings']['temp_directory'] = [
    '#type' => 'textfield',
    '#title' => $this
      ->t('Temporary directory'),
    '#description' => $this
      ->t('A local file system path where temporary export files will be stored. This directory should be persistent between requests and should not be accessible over the web.'),
    '#required' => TRUE,
    '#default_value' => $config
      ->get('export.temp_directory') ?: $this->fileSystem
      ->getTempDirectory(),
  ];

  // Export.
  $form['export_default_settings'] = [
    '#type' => 'details',
    '#title' => $this
      ->t('Export default settings'),
    '#description' => $this
      ->t('Enter default export settings to be used by all webforms.'),
    '#open' => TRUE,
  ];
  $export_options = $config
    ->get('export');
  $export_form_state = new FormState();
  $this->submissionExporter
    ->buildExportOptionsForm($form['export_default_settings'], $export_form_state, $export_options);

  // (Excluded) Exporters.
  $form['exporter_types'] = [
    '#type' => 'details',
    '#title' => $this
      ->t('Submission exporters'),
    '#description' => $this
      ->t('Select available submission exporters'),
    '#open' => TRUE,
  ];
  $form['exporter_types']['excluded_exporters'] = $this
    ->buildExcludedPlugins($this->exporterManager, $config
    ->get('export.excluded_exporters') ?: [] ?: []);
  return parent::buildForm($form, $form_state);
}