You are here

public function SecuritytxtSignForm::buildForm in Security.txt 8

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/SecuritytxtSignForm.php, line 58

Class

SecuritytxtSignForm
Upload the security.txt.sig file.

Namespace

Drupal\securitytxt\Form

Code

public function buildForm(array $form, FormStateInterface $form_state) {
  $enabled = $this->settings
    ->get('enabled');
  if (!$enabled) {
    $form['instructions'] = [
      '#type' => 'markup',
      '#markup' => '<p>' . $this
        ->t('You must <a href=":configure">configure and enable</a> your security.txt file before you can sign it.', [
        ':configure' => Url::fromRoute('securitytxt.configure')
          ->toString(),
      ]) . '</p>',
    ];
    return $form;
  }
  $form['instructions'] = [
    '#type' => 'markup',
    '#markup' => '<ol>' . '<li>' . $this
      ->t('<a href=":download" download="security.txt">Download</a> your security.txt file.', [
      ':download' => Url::fromRoute('securitytxt.securitytxt_file')
        ->toString(),
    ]) . '</li>' . '<li><p>Sign your security.txt file with the encryption key you specified in your security.txt file. This can be done with the following GPG command:</p><p><kbd>gpg -u KEYID --output security.txt.sig  --armor --detach-sig security.txt</kbd></p></li>' . '<li>Paste the contents of the <kbd>security.txt.sig</kbd> file into the text box below.</li>' . '</ol>',
  ];
  $form['signature_text'] = [
    '#type' => 'textarea',
    '#title' => $this
      ->t('Signature'),
    '#default_value' => $this->settings
      ->get('signature_text'),
    '#rows' => 20,
  ];
  return parent::buildForm($form, $form_state);
}