You are here

public function PurgeBlock::blockForm in Purge 8.3

Overrides BlockPluginTrait::blockForm

File

modules/purge_ui/src/Plugin/Block/PurgeBlock.php, line 78

Class

PurgeBlock
Let site administrators purge the current page.

Namespace

Drupal\purge_ui\Plugin\Block

Code

public function blockForm($form, FormStateInterface $form_state) {
  $form = parent::blockForm($form, $form_state);
  $config = $this
    ->getConfiguration();
  $form['purge_block_id'] = [
    '#type' => 'hidden',
    '#value' => $config['purge_block_id'],
  ];
  $form['description'] = [
    '#type' => 'textfield',
    '#title' => $this
      ->t('Description'),
    '#description' => $this
      ->t('Provide an optional description text which will be shown above the submit button.'),
    '#default_value' => $config['description'],
  ];
  $form['submission'] = [
    '#type' => 'details',
    '#title' => $this
      ->t('Submission'),
  ];
  $form['submission']['submit_label'] = [
    '#size' => 30,
    '#type' => 'textfield',
    '#title' => $this
      ->t('Label'),
    '#description' => $this
      ->t('Provide the label of the submit button, this is what the user clicks on.'),
    '#default_value' => $config['submit_label'],
  ];
  $form['submission']['type'] = [
    '#type' => 'radios',
    '#title' => $this
      ->t('Invalidation type'),
    '#default_value' => $config['type'],
    '#description' => $this
      ->t('<b>Warning:</b> only select a type which is actually supported by your purgers!'),
    '#options' => [
      'url' => $this
        ->t("The current page's <b>url</b>."),
      'path' => $this
        ->t("The <b>path</b> of the current page."),
      'everything' => $this
        ->t('<b>everything</b> on the entire site.'),
    ],
  ];
  $form['submission']['execution'] = [
    '#type' => 'radios',
    '#title' => $this
      ->t('Execution'),
    '#default_value' => $config['execution'],
    '#description' => $this
      ->t('With direct execution, the user gets immedate feedback whether the cache invalidation succeeded or failed. The drawback is that failures, will not be queued for later retries.'),
    '#options' => [
      'direct' => $this
        ->t("Direct execution"),
      'queue' => $this
        ->t("Through queue"),
    ],
  ];
  return $form;
}