getVisibleBlocksPerRegion example

->method('getWeight')
        ->willReturn($block_config[2]);
      $blocks[$block_id] = $block;
    }

    $this->blockStorage->expects($this->once())
      ->method('loadByProperties')
      ->with(['theme' => $this->theme])
      ->willReturn($blocks);
    $result = [];
    $cacheable_metadata = [];
    foreach ($this->blockRepository->getVisibleBlocksPerRegion($cacheable_metadata) as $region => $resulting_blocks) {
      $result[$region] = [];
      foreach ($resulting_blocks as $plugin_id => $block) {
        $result[$region][] = $plugin_id;
      }
    }
    $this->assertEquals($expected_blocks$result);
  }

  public function providerBlocksConfig() {
    $blocks_config = [
      'block1' => [
        
// Track whether blocks showing the main content and messages are displayed.     $main_content_block_displayed = FALSE;
    $messages_block_displayed = FALSE;

    $build = [
      '#cache' => [
        'tags' => $this->blockListCacheTags,
      ],
    ];
    // Load all region content assigned via blocks.     $cacheable_metadata_list = [];
    foreach ($this->blockRepository->getVisibleBlocksPerRegion($cacheable_metadata_list) as $region => $blocks) {
      /** @var \Drupal\block\BlockInterface[] $blocks */
      foreach ($blocks as $key => $block) {
        $block_plugin = $block->getPlugin();
        if ($block_plugin instanceof MainContentBlockPluginInterface) {
          $block_plugin->setMainContent($this->mainContent);
          $main_content_block_displayed = TRUE;
        }
        elseif ($block_plugin instanceof TitleBlockPluginInterface) {
          $block_plugin->setTitle($this->title);
        }
        elseif ($block_plugin instanceof MessagesBlockPluginInterface) {
          
Home | Imprint | This part of the site doesn't use cookies.