You are here

public function ViewsBlockArea::buildOptionsForm in Views block area 8

Provide a form to edit options for this plugin.

Overrides AreaPluginBase::buildOptionsForm

File

src/Plugin/views/area/ViewsBlockArea.php, line 82
Contains \Drupal\block\Plugin\views\area\Block.

Class

ViewsBlockArea
Provides an area handler which renders a block entity in a certain view mode.

Namespace

Drupal\views_block_area\Plugin\views\area

Code

public function buildOptionsForm(&$form, FormStateInterface $form_state) {
  parent::buildOptionsForm($form, $form_state);
  $options = [];

  /** @var \Drupal\block_field\BlockFieldManagerInterface $block_field_manager */
  $definitions = $this
    ->getBlockDefinitions();
  foreach ($definitions as $id => $definition) {

    // If allowed plugin ids are set then check that this block should be
    // included.
    $category = (string) $definition['category'];
    $options[$category][$id] = $definition['admin_label'];
  }
  $form['block_id'] = [
    '#type' => 'select',
    '#title' => $this
      ->t('Block'),
    '#options' => $options,
    '#empty_option' => $this
      ->t('Please select'),
    '#default_value' => $this->options['block_id'],
  ];
}