function block_page_top

Same name in other branches
  1. 9 core/modules/block/block.module \block_page_top()
  2. 8.9.x core/modules/block/block.module \block_page_top()
  3. 11.x core/modules/block/block.module \block_page_top()

Implements hook_page_top().

File

core/modules/block/block.module, line 68

Code

function block_page_top(array &$page_top) {
    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,
            ]);
        }
    }
}

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