Skip to main content
Drupal API
User account menu
  • Log in

Breadcrumb

  1. Drupal Core 11.1.x
  2. BlockHooks.php

function BlockHooks::pageTop

Implements hook_page_top().

File

core/modules/block/src/Hook/BlockHooks.php, line 67

Class

BlockHooks
Hook implementations for block.

Namespace

Drupal\block\Hook

Code

public function pageTop(array &$page_top) : void {
    if (\Drupal::routeMatch()->getRouteName() === 'block.admin_demo') {
        $theme = \Drupal::theme()->getActiveTheme()
            ->getName();
        $page_top['backlink'] = [
            '#type' => 'link',
            '#title' => t('Exit block region demonstration'),
            '#options' => [
                'attributes' => [
                    'class' => [
                        'block-demo-backlink',
                    ],
                ],
            ],
            '#weight' => -10,
        ];
        if (\Drupal::config('system.theme')->get('default') == $theme) {
            $page_top['backlink']['#url'] = Url::fromRoute('block.admin_display');
        }
        else {
            $page_top['backlink']['#url'] = Url::fromRoute('block.admin_display_theme', [
                'theme' => $theme,
            ]);
        }
    }
}

API Navigation

  • Drupal Core 11.1.x
  • Topics
  • Classes
  • Functions
  • Constants
  • Globals
  • Files
  • Namespaces
  • Deprecated
  • Services
RSS feed
Powered by Drupal