NavigationTestBlock.php

Namespace

Drupal\navigation_test_block\Plugin\Block

File

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

View source
<?php

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

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

/**
 * Defines a dummy navigation block for testing purposes.
 *
 * @internal
 */
final class NavigationTestBlock extends BlockBase {
    
    /**
     * {@inheritdoc}
     */
    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>'),
                ],
            ],
        ];
    }

}

Classes

Title Deprecated Summary
NavigationTestBlock Defines a dummy navigation block for testing purposes.

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