function AggregatorFeedBlock::blockForm

Same name in other branches
  1. 9 core/modules/aggregator/src/Plugin/Block/AggregatorFeedBlock.php \Drupal\aggregator\Plugin\Block\AggregatorFeedBlock::blockForm()

File

core/modules/aggregator/src/Plugin/Block/AggregatorFeedBlock.php, line 95

Class

AggregatorFeedBlock
Provides an 'Aggregator feed' block with the latest items from the feed.

Namespace

Drupal\aggregator\Plugin\Block

Code

public function blockForm($form, FormStateInterface $form_state) {
    $feeds = $this->feedStorage
        ->loadMultiple();
    $options = [];
    foreach ($feeds as $feed) {
        $options[$feed->id()] = $feed->label();
    }
    $form['feed'] = [
        '#type' => 'select',
        '#title' => $this->t('Select the feed that should be displayed'),
        '#default_value' => $this->configuration['feed'],
        '#options' => $options,
    ];
    $range = range(2, 20);
    $form['block_count'] = [
        '#type' => 'select',
        '#title' => $this->t('Number of news items in block'),
        '#default_value' => $this->configuration['block_count'],
        '#options' => array_combine($range, $range),
    ];
    return $form;
}

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