$page =
$main_content;
$title =
$get_title($page);
} // Otherwise, render it as the main content of a #type => page, by selecting
// page display variant to do that and building that page display variant.
else { // Select the page display variant to be used to render this main content,
// default to the built-in "simple page".
$event =
new PageDisplayVariantSelectionEvent('simple_page',
$route_match);
$this->eventDispatcher->
dispatch($event, RenderEvents::SELECT_PAGE_DISPLAY_VARIANT
);
$variant_id =
$event->
getPluginId();
$variant_configuration =
$event->
getPluginConfiguration();
// We must render the main content now already, because it might provide a
// title. We set its $is_root_call parameter to FALSE, to ensure
// placeholders are not yet replaced. This is essentially "pre-rendering"
// the main content, the "full rendering" will happen in
// ::renderResponse().
// @todo Remove this once https://www.drupal.org/node/2359901 lands.
if (!
empty($main_content)) { $this->renderer->
executeInRenderContext(new RenderContext(),
function D
) use (&
$main_content) { if (isset($main_content['#cache'
]['keys'
])) { // Retain #title, otherwise, dynamically generated titles would be