You are here

protected function BlockVisibilityGroupedListBuilder::getBlockVisibilityGroupOptions in Block Visibility Groups 8

Get Group options info to group select dropdown.

Return value

array Keys = Group keys Values array with keys: label path - URL to redirect to Group page.

1 call to BlockVisibilityGroupedListBuilder::getBlockVisibilityGroupOptions()
BlockVisibilityGroupedListBuilder::buildForm in src/BlockVisibilityGroupedListBuilder.php
Form constructor.

File

src/BlockVisibilityGroupedListBuilder.php, line 202

Class

BlockVisibilityGroupedListBuilder
Extends BlockListBuilder to add our elements only show certain blocks.

Namespace

Drupal\block_visibility_groups

Code

protected function getBlockVisibilityGroupOptions() {
  $route_options = [
    BlockVisibilityGroupedListBuilder::UNSET_GROUP => [
      'label' => $this
        ->t('- Global blocks -'),
    ],
    BlockVisibilityGroupedListBuilder::ALL_GROUP => [
      'label' => $this
        ->t('- All Blocks -'),
    ],
  ];
  $block_visibility_group_labels = $this
    ->getBlockVisibilityLabels($this->group_storage);
  foreach ($block_visibility_group_labels as $id => $label) {
    $route_options[$id] = [
      'label' => $label,
    ];
  }
  foreach ($route_options as $key => &$route_option) {
    $url = Url::fromRoute('block.admin_display_theme', [
      'theme' => $this->theme,
    ], [
      'query' => [
        'block_visibility_group' => $key,
      ],
    ]);
    $route_option['path'] = $url
      ->toString();
  }
  return $route_options;
}