You are here

public function DatexBlock::blockSubmit in Datex 8

Overrides BlockPluginTrait::blockSubmit

File

src/Plugin/Block/DatexBlock.php, line 77

Class

DatexBlock
Provides a block to show a localized current/relative date.

Namespace

Drupal\datex\Plugin\Block

Code

public function blockSubmit($form, FormStateInterface $form_state) {
  $this
    ->setConfigurationValue('fmt', $form_state
    ->getValue('datex_fmt'));
  $this
    ->setConfigurationValue('cal', $form_state
    ->getValue('datex_calendar'));
  $this
    ->setConfigurationValue('tz', $form_state
    ->getValue('datex_tz'));
  if (strpos($form_state
    ->getValue('datex_text'), '{}') < 0) {
    drupal_set_message(t('Invalid content, content set to {}'), 'warning');
    $this
      ->setConfigurationValue('text', '{}');
  }
  else {
    $this
      ->setConfigurationValue('text', $form_state
      ->getValue('datex_text'));
  }
  $c = $form_state
    ->getValue('datex_cache');
  if ($c !== '' && is_numeric($c) && $c >= 0) {
    $this
      ->setConfigurationValue('cache', $form_state
      ->getValue('datex_cache'));
  }
  else {
    drupal_set_message('block cache time set to one hour');
    $this
      ->setConfigurationValue('cache', 3600);
  }
}