You are here

public function PrintableLinksBlock::buildConfigurationForm in Printer and PDF versions for Drupal 8+ 8

Same name and namespace in other branches
  1. 2.x src/Plugin/Block/PrintableLinksBlock.php \Drupal\printable\Plugin\Block\PrintableLinksBlock::buildConfigurationForm()

Creates a generic configuration form for all block types. Individual block plugins can add elements to this form by overriding BlockBase::blockForm(). Most block plugins should not override this method unless they need to alter the generic form elements.

Overrides BlockPluginTrait::buildConfigurationForm

See also

\Drupal\Core\Block\BlockBase::blockForm()

File

src/Plugin/Block/PrintableLinksBlock.php, line 87

Class

PrintableLinksBlock
Provides a printable links block for each printable entity.

Namespace

Drupal\printable\Plugin\Block

Code

public function buildConfigurationForm(array $form, FormStateInterface $form_state) {
  $form += parent::buildConfigurationForm($form, $form_state);
  $period = [
    0,
    60,
    180,
    300,
    600,
    900,
    1800,
    2700,
    3600,
    10800,
    21600,
    32400,
    43200,
    86400,
  ];
  $period = array_map([
    $this->dateFormatter,
    'formatInterval',
  ], array_combine($period, $period));
  $period[0] = '<' . $this
    ->t('no caching') . '>';
  $period[Cache::PERMANENT] = $this
    ->t('Forever');
  $form['cache'] = [
    '#type' => 'details',
    '#title' => $this
      ->t('Cache settings'),
  ];
  $form['cache']['max_age'] = [
    '#type' => 'select',
    '#title' => $this
      ->t('Maximum age'),
    '#description' => $this
      ->t('The maximum time this block may be cached.'),
    '#default_value' => $period[0],
    '#options' => $period,
  ];
  return $form;
}