function StatisticsPopularBlock::blockForm

Same name in other branches
  1. 9 core/modules/statistics/src/Plugin/Block/StatisticsPopularBlock.php \Drupal\statistics\Plugin\Block\StatisticsPopularBlock::blockForm()
  2. 8.9.x core/modules/statistics/src/Plugin/Block/StatisticsPopularBlock.php \Drupal\statistics\Plugin\Block\StatisticsPopularBlock::blockForm()
  3. 11.x core/modules/statistics/src/Plugin/Block/StatisticsPopularBlock.php \Drupal\statistics\Plugin\Block\StatisticsPopularBlock::blockForm()

Overrides BlockPluginTrait::blockForm

File

core/modules/statistics/src/Plugin/Block/StatisticsPopularBlock.php, line 117

Class

StatisticsPopularBlock
Provides a 'Popular content' block.

Namespace

Drupal\statistics\Plugin\Block

Code

public function blockForm($form, FormStateInterface $form_state) {
    // Popular content block settings.
    $numbers = [
        1,
        2,
        3,
        4,
        5,
        6,
        7,
        8,
        9,
        10,
        15,
        20,
        25,
        30,
        40,
    ];
    $numbers = [
        '0' => $this->t('Disabled'),
    ] + array_combine($numbers, $numbers);
    $form['statistics_block_top_day_num'] = [
        '#type' => 'select',
        '#title' => $this->t("Number of day's top views to display"),
        '#default_value' => $this->configuration['top_day_num'],
        '#options' => $numbers,
        '#description' => $this->t('How many content items to display in "day" list.'),
    ];
    $form['statistics_block_top_all_num'] = [
        '#type' => 'select',
        '#title' => $this->t('Number of all time views to display'),
        '#default_value' => $this->configuration['top_all_num'],
        '#options' => $numbers,
        '#description' => $this->t('How many content items to display in "all time" list.'),
    ];
    $form['statistics_block_top_last_num'] = [
        '#type' => 'select',
        '#title' => $this->t('Number of most recent views to display'),
        '#default_value' => $this->configuration['top_last_num'],
        '#options' => $numbers,
        '#description' => $this->t('How many content items to display in "recently viewed" list.'),
    ];
    return $form;
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.