NavigationTestHooks.php

Namespace

Drupal\navigation_test\Hook

File

core/modules/navigation/tests/navigation_test/src/Hook/NavigationTestHooks.php

View source
<?php

declare (strict_types=1);
namespace Drupal\navigation_test\Hook;

use Drupal\Core\Hook\Attribute\Hook;
use Drupal\Core\State\StateInterface;

/**
 * Hooks implementations for navigation_test module.
 */
class NavigationTestHooks {
    
    /**
     * NavigationTestHooks constructor.
     *
     * @param \Drupal\Core\State\StateInterface $state
     *   The state service.
     */
    public function __construct(StateInterface $state) {
    }
    
    /**
     * Implements hook_block_alter().
     */
    public function blockAlter(&$definitions) : void {
        if ($this->state
            ->get('navigation_safe_alter')) {
            $definitions['navigation_link']['allow_in_navigation'] = TRUE;
            $definitions['navigation_shortcuts']['allow_in_navigation'] = FALSE;
        }
    }

}

Classes

Title Deprecated Summary
NavigationTestHooks Hooks implementations for navigation_test module.

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