// 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
) {