You are here

public function SettingsForm::buildForm in File metadata manager 8

Same name and namespace in other branches
  1. 8.2 src/Form/SettingsForm.php \Drupal\file_mdm\Form\SettingsForm::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/SettingsForm.php, line 69

Class

SettingsForm
Configures file_mdm settings for this site.

Namespace

Drupal\file_mdm\Form

Code

public function buildForm(array $form, FormStateInterface $form_state) {

  // Cache metadata.
  $form['metadata_cache'] = [
    '#type' => 'details',
    '#open' => TRUE,
    '#collapsible' => FALSE,
    '#title' => $this
      ->t('Metadata caching'),
    '#tree' => TRUE,
  ];
  $form['metadata_cache']['settings'] = [
    '#type' => 'file_mdm_caching',
    '#default_value' => $this
      ->config('file_mdm.settings')
      ->get('metadata_cache'),
  ];

  // Settings tabs.
  $form['plugins'] = [
    '#type' => 'vertical_tabs',
    '#tree' => FALSE,
  ];

  // Load subforms from each plugin.
  foreach ($this->metadataPlugins as $id => $plugin) {
    $definition = $plugin
      ->getPluginDefinition();
    $form['file_mdm_plugin_settings'][$id] = [
      '#type' => 'details',
      '#title' => $definition['title'],
      '#description' => $definition['help'],
      '#open' => FALSE,
      '#tree' => TRUE,
      '#group' => 'plugins',
    ];
    $form['file_mdm_plugin_settings'][$id] += $plugin
      ->buildConfigurationForm([], $form_state);
  }
  return parent::buildForm($form, $form_state);
}