function NodeThemeHooks::pageTop

Implements hook_page_top().

Attributes

#[Hook('page_top')]

File

core/modules/node/src/Hook/NodeThemeHooks.php, line 271

Class

NodeThemeHooks
Theme hook implementations for the node module.

Namespace

Drupal\node\Hook

Code

public function pageTop(array &$page_top) : void {
  // Add 'Back to content editing' link on preview page.
  if ($this->routeMatch
    ->getRouteName() == 'entity.node.preview') {
    $page_top['node_preview'] = [
      '#type' => 'container',
      '#attributes' => [
        'class' => [
          'node-preview-container',
          'container-inline',
        ],
      ],
      'view_mode' => $this->formBuilder
        ->getForm(NodePreviewForm::class, $this->routeMatch
        ->getParameter('node_preview')),
    ];
  }
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.