You are here

public function BlockLibraryGroupsController::listBlocks in Block Visibility Groups 8

Shows a list of blocks that can be added to a theme's layout.

Parameters

\Symfony\Component\HttpFoundation\Request $request: The current request.

string $theme: Theme key of the block list.

Return value

array A render array as expected by the renderer.

Overrides BlockLibraryController::listBlocks

1 string reference to 'BlockLibraryGroupsController::listBlocks'
block_visibility_groups.routing.yml in ./block_visibility_groups.routing.yml
block_visibility_groups.routing.yml

File

src/Controller/BlockLibraryGroupsController.php, line 17

Class

BlockLibraryGroupsController
Provides a list of block plugins to be added to the layout.

Namespace

Drupal\block_visibility_groups\Controller

Code

public function listBlocks(Request $request, $theme, BlockVisibilityGroup $block_visibility_group = NULL) {
  $list = parent::listBlocks($request, $theme);
  if ($block_visibility_group) {
    foreach ($list['blocks']['#rows'] as &$row) {
      $row['operations']['data']['#links']['add']['query']['block_visibility_group'] = $block_visibility_group
        ->id();
    }
  }
  return $list;
}