function NavigationTestBlock::build

File

core/modules/navigation/tests/navigation_test_block/src/Plugin/Block/NavigationTestBlock.php, line 26

Class

NavigationTestBlock
Defines a dummy navigation block for testing purposes.

Namespace

Drupal\navigation_test_block\Plugin\Block

Code

public function build() : array {
    $config = $this->configuration;
    $build = [];
    return $build + [
        '#title' => $config['label'],
        '#theme' => 'navigation_menu',
        '#menu_name' => 'test',
        '#items' => [
            [
                'title' => 'Test Navigation Block',
                'class' => 'test-block',
                'url' => Url::fromRoute('<front>'),
            ],
        ],
    ];
}

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