You are here

public function SettingsForm::buildForm in Bibliography & Citation 8

Same name in this branch
  1. 8 src/Form/SettingsForm.php \Drupal\bibcite\Form\SettingsForm::buildForm()
  2. 8 modules/bibcite_import/src/Form/SettingsForm.php \Drupal\bibcite_import\Form\SettingsForm::buildForm()
Same name and namespace in other branches
  1. 2.0.x src/Form/SettingsForm.php \Drupal\bibcite\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 60

Class

SettingsForm
Common configuration.

Namespace

Drupal\bibcite\Form

Code

public function buildForm(array $form, FormStateInterface $form_state) {
  $config = $this
    ->config('bibcite.settings');
  $processor_definitions = $this->styler
    ->getAvailableProcessors();
  $processor_options = array_map(function ($definition) {
    return $definition['label'];
  }, $processor_definitions);
  $form['processor'] = [
    '#type' => 'select',
    '#options' => $processor_options,
    '#title' => $this
      ->t('Processor'),
    '#default_value' => $config
      ->get('processor'),
  ];
  $csl_styles = $this->styler
    ->getAvailableStyles();
  $styles_options = array_map(function ($entity) {

    /** @var \Drupal\bibcite\Entity\CslStyleInterface $entity */
    return $entity
      ->label();
  }, $csl_styles);
  $form['default_style'] = [
    '#type' => 'select',
    '#title' => $this
      ->t('Default style'),
    '#options' => $styles_options,
    '#default_value' => $config
      ->get('default_style'),
  ];
  return parent::buildForm($form, $form_state);
}