Chris@0: routeMatch = $route_match; Chris@0: } Chris@0: Chris@0: /** Chris@0: * {@inheritdoc} Chris@0: */ Chris@0: public static function create(ContainerInterface $container) { Chris@0: return new static( Chris@0: $container->get('current_route_match') Chris@0: ); Chris@0: } Chris@0: Chris@0: /** Chris@0: * @param array $variables Chris@0: * Theme variables to preprocess. Chris@0: * Chris@0: * @see hook_preprocess_HOOK() Chris@0: */ Chris@0: public function preprocessNode(array &$variables) { Chris@0: // Set the 'page' template variable when the node is being displayed on the Chris@0: // "Latest version" tab provided by content_moderation. Chris@0: $variables['page'] = $variables['page'] || $this->isLatestVersionPage($variables['node']); Chris@0: } Chris@0: Chris@0: /** Chris@0: * Checks whether a route is the "Latest version" tab of a node. Chris@0: * Chris@0: * @param \Drupal\node\Entity\Node $node Chris@0: * A node. Chris@0: * Chris@0: * @return bool Chris@0: * True if the current route is the latest version tab of the given node. Chris@0: */ Chris@0: public function isLatestVersionPage(Node $node) { Chris@0: return $this->routeMatch->getRouteName() == 'entity.node.latest_version' Chris@0: && ($pageNode = $this->routeMatch->getParameter('node')) Chris@0: && $pageNode->id() == $node->id(); Chris@0: } Chris@0: Chris@0: }