You are here

public function DisclaimerBlock::blockForm in Disclaimer 8

Overrides BlockPluginTrait::blockForm

File

src/Plugin/Block/DisclaimerBlock.php, line 107

Class

DisclaimerBlock
Provides a 'DisclaimerBlock' block.

Namespace

Drupal\disclaimer\Plugin\Block

Code

public function blockForm($form, FormStateInterface $form_state) {
  $form['redirect'] = [
    '#type' => 'textfield',
    '#title' => $this
      ->t('Redirect'),
    '#description' => $this
      ->t('The URL a rejected user is sent to. eg. /content-for-unconfirmed-users. (relative, absolute, <front>)'),
    '#default_value' => $this->configuration['redirect'],
    '#maxlength' => 256,
    '#size' => 64,
    '#required' => TRUE,
    '#weight' => 10,
  ];
  $form['max_age'] = [
    '#type' => 'textfield',
    '#title' => $this
      ->t('Max-age'),
    '#description' => $this
      ->t('The time in seconds the user is confirmed. Set to 0 for no expiry. (86400 seconds = 24 hours)'),
    '#default_value' => $this->configuration['max_age'],
    '#maxlength' => 64,
    '#size' => 64,
    '#required' => TRUE,
    '#weight' => 20,
  ];
  $form['challenge'] = [
    '#type' => 'text_format',
    '#format' => $this->configuration['challenge']['format'],
    '#title' => $this
      ->t('Challenge'),
    '#description' => $this
      ->t('The question the user must confirm. "Do you agree?" type of question. <em>Agree</em> = User stays on requested page. <em>Disagree</em> = User is redirected to <em>Redirect</em> url specified below.'),
    '#default_value' => $this->configuration['challenge']['value'],
    '#required' => TRUE,
    '#weight' => 30,
  ];
  $form['agree'] = [
    '#type' => 'textfield',
    '#title' => $this
      ->t('Agree button'),
    '#description' => $this
      ->t('Label for <em>Agree</em> button on challenge.'),
    '#default_value' => $this->configuration['agree'],
    '#maxlength' => 64,
    '#size' => 64,
    '#required' => TRUE,
    '#weight' => 40,
  ];
  $form['disagree'] = [
    '#type' => 'textfield',
    '#title' => $this
      ->t('Disagree button'),
    '#description' => $this
      ->t('Label for <em>Disagree</em> button on challenge.'),
    '#default_value' => $this->configuration['disagree'],
    '#maxlength' => 64,
    '#size' => 64,
    '#required' => TRUE,
    '#weight' => 50,
  ];
  $form['disclaimer'] = [
    '#type' => 'text_format',
    '#format' => $this->configuration['disclaimer']['format'],
    '#title' => $this
      ->t('Disclaimer'),
    '#description' => $this
      ->t('The text displayed to the user on a protected page when the user has JS turned off. (No popup with challenge is available.)'),
    '#default_value' => $this->configuration['disclaimer']['value'],
    '#weight' => 60,
    '#required' => FALSE,
  ];
  return $form;
}