} $title =
$get_title($main_content);
// Instantiate the page display, and give it the main content.
$page_display =
$this->displayVariantManager->
createInstance($variant_id,
$variant_configuration);
if (!
$page_display instanceof PageVariantInterface
) { throw new \
LogicException('Cannot render the main content for this page because the provided display variant does not implement PageVariantInterface.'
);
} $page_display ->
setMainContent($main_content) ->
setTitle($title) ->
addCacheableDependency($event);
// Some display variants need to be passed an array of contexts with
// values because they can't get all their contexts globally. For example,
// in Page Manager, you can create a Page which has a specific static
// context (e.g. a context that refers to the Node with nid 6), if any
// such contexts were added to the $event, pass them to the $page_display.
if ($page_display instanceof ContextAwareVariantInterface
) { $page_display->
setContexts($event->
getContexts());
}