PageDisplayVariantSelectionEvent example

    // we have no work to do: The "main content" already is an entire "page"     // (see html.html.twig).     if (isset($main_content['#type']) && $main_content['#type'] === 'page') {
      $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)) {
        
Home | Imprint | This part of the site doesn't use cookies.