function SettingsForm::buildForm

Same name in this branch
  1. 11.x core/modules/navigation/src/Form/SettingsForm.php \Drupal\navigation\Form\SettingsForm::buildForm()
  2. 11.x core/modules/media_library/src/Form/SettingsForm.php \Drupal\media_library\Form\SettingsForm::buildForm()
Same name and namespace in other branches
  1. 9 core/modules/media_library/src/Form/SettingsForm.php \Drupal\media_library\Form\SettingsForm::buildForm()
  2. 9 core/modules/aggregator/src/Form/SettingsForm.php \Drupal\aggregator\Form\SettingsForm::buildForm()

Overrides ConfigFormBase::buildForm

File

core/modules/package_manager/src/Form/SettingsForm.php, line 33

Class

SettingsForm
Configures Package Manager settings.

Namespace

Drupal\package_manager\Form

Code

public function buildForm(array $form, FormStateInterface $form_state) : array {
  $form['executables'] = [
    '#type' => 'details',
    '#title' => $this->t('Executable paths'),
    '#open' => TRUE,
    '#description' => $this->t('Configure the paths to required executables.'),
  ];
  $trim = fn(string $value): string => trim($value);
  $form['executables']['composer'] = [
    '#type' => 'textfield',
    '#title' => $this->t('Composer executable path'),
    '#config_target' => new ConfigTarget('package_manager.settings', 'executables.composer', toConfig: $trim),
    '#description' => $this->t('The full path to the <code>composer</code> executable (e.g., <code>/usr/local/bin/composer</code>).'),
    '#required' => TRUE,
  ];
  $form['executables']['rsync'] = [
    '#type' => 'textfield',
    '#title' => $this->t('rsync executable path'),
    '#config_target' => new ConfigTarget('package_manager.settings', 'executables.rsync', toConfig: $trim),
    '#description' => $this->t('The full path to the <code>rsync</code> executable (e.g., <code>/usr/bin/rsync</code>).'),
    '#required' => TRUE,
  ];
  return parent::buildForm($form, $form_state);
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.