You are here

public function AggregatorFeedBlock::blockForm in Zircon Profile 8

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

Returns the configuration form elements specific to this block plugin.

Blocks that need to add form elements to the normal block configuration form should implement this method.

Parameters

array $form: The form definition array for the block configuration form.

\Drupal\Core\Form\FormStateInterface $form_state: The current state of the form.

Return value

array $form The renderable form array representing the entire configuration form.

Overrides BlockBase::blockForm

File

core/modules/aggregator/src/Plugin/Block/AggregatorFeedBlock.php, line 114
Contains \Drupal\aggregator\Plugin\Block\AggregatorFeedBlock.

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 = array();
  foreach ($feeds as $feed) {
    $options[$feed
      ->id()] = $feed
      ->label();
  }
  $form['feed'] = array(
    '#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'] = array(
    '#type' => 'select',
    '#title' => $this
      ->t('Number of news items in block'),
    '#default_value' => $this->configuration['block_count'],
    '#options' => array_combine($range, $range),
  );
  return $form;
}