NavigationUserBlock.php

Same filename in other branches
  1. 11.x core/modules/navigation/src/Plugin/Block/NavigationUserBlock.php

Namespace

Drupal\navigation\Plugin\Block

File

core/modules/navigation/src/Plugin/Block/NavigationUserBlock.php

View source
<?php

declare (strict_types=1);
namespace Drupal\navigation\Plugin\Block;

use Drupal\Core\Block\Attribute\Block;
use Drupal\Core\Block\BlockBase;
use Drupal\Core\StringTranslation\TranslatableMarkup;

/**
 * Defines a user navigation block.
 *
 * @internal
 */
final class NavigationUserBlock extends BlockBase {
    
    /**
     * {@inheritdoc}
     */
    public function build() : array {
        return [
            'user' => [
                '#lazy_builder' => [
                    'navigation.user_lazy_builder:renderNavigationLinks',
                    [],
                ],
                '#create_placeholder' => TRUE,
                '#cache' => [
                    'keys' => [
                        'user_set_navigation_links',
                    ],
                    'contexts' => [
                        'user',
                    ],
                ],
                '#lazy_builder_preview' => [
                    '#markup' => '<a href="#" class="toolbar-tray-lazy-placeholder-link">&nbsp;</a>',
                ],
            ],
        ];
    }

}

Classes

Title Deprecated Summary
NavigationUserBlock Defines a user navigation block.

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