summaryrefslogtreecommitdiffstatshomepage
path: root/core/modules/toolbar
diff options
context:
space:
mode:
Diffstat (limited to 'core/modules/toolbar')
-rw-r--r--core/modules/toolbar/src/Hook/ToolbarThemeHooks.php23
-rw-r--r--core/modules/toolbar/tests/modules/toolbar_test/src/Hook/ToolbarTestThemeHooks.php30
-rw-r--r--core/modules/toolbar/tests/modules/toolbar_test/toolbar_test.module19
-rw-r--r--core/modules/toolbar/tests/src/FunctionalJavascript/ToolbarActiveTrailTest.php10
-rw-r--r--core/modules/toolbar/tests/src/FunctionalJavascript/ToolbarIntegrationTest.php4
-rw-r--r--core/modules/toolbar/tests/src/FunctionalJavascript/ToolbarStoredStateTest.php4
-rw-r--r--core/modules/toolbar/toolbar.module11
7 files changed, 62 insertions, 39 deletions
diff --git a/core/modules/toolbar/src/Hook/ToolbarThemeHooks.php b/core/modules/toolbar/src/Hook/ToolbarThemeHooks.php
new file mode 100644
index 00000000000..fb08f0ffde6
--- /dev/null
+++ b/core/modules/toolbar/src/Hook/ToolbarThemeHooks.php
@@ -0,0 +1,23 @@
+<?php
+
+namespace Drupal\toolbar\Hook;
+
+use Drupal\Core\Hook\Attribute\Hook;
+
+/**
+ * Hook implementations for toolbar.
+ */
+class ToolbarThemeHooks {
+
+ /**
+ * Implements hook_preprocess_HOOK() for HTML document templates.
+ */
+ #[Hook('preprocess_html')]
+ public function preprocessHtml(&$variables): void {
+ if (!\Drupal::currentUser()->hasPermission('access toolbar')) {
+ return;
+ }
+ $variables['attributes']['class'][] = 'toolbar-loading';
+ }
+
+}
diff --git a/core/modules/toolbar/tests/modules/toolbar_test/src/Hook/ToolbarTestThemeHooks.php b/core/modules/toolbar/tests/modules/toolbar_test/src/Hook/ToolbarTestThemeHooks.php
new file mode 100644
index 00000000000..e1d40c8219a
--- /dev/null
+++ b/core/modules/toolbar/tests/modules/toolbar_test/src/Hook/ToolbarTestThemeHooks.php
@@ -0,0 +1,30 @@
+<?php
+
+declare(strict_types=1);
+
+namespace Drupal\toolbar_test\Hook;
+
+use Drupal\Core\Hook\Attribute\Hook;
+
+/**
+ * Hook implementations for toolbar_test.
+ */
+class ToolbarTestThemeHooks {
+
+ /**
+ * Implements hook_preprocess_HOOK().
+ */
+ #[Hook('preprocess_menu')]
+ public function preprocessMenu(&$variables): void {
+ // All the standard hook_theme variables should be populated when the
+ // Toolbar module is rendering a menu.
+ foreach ([
+ 'menu_name',
+ 'items',
+ 'attributes',
+ ] as $variable) {
+ $variables[$variable];
+ }
+ }
+
+}
diff --git a/core/modules/toolbar/tests/modules/toolbar_test/toolbar_test.module b/core/modules/toolbar/tests/modules/toolbar_test/toolbar_test.module
deleted file mode 100644
index 8980eb4a6ef..00000000000
--- a/core/modules/toolbar/tests/modules/toolbar_test/toolbar_test.module
+++ /dev/null
@@ -1,19 +0,0 @@
-<?php
-
-/**
- * @file
- * A dummy module to test API interaction with the Toolbar module.
- */
-
-declare(strict_types=1);
-
-/**
- * Implements hook_preprocess_HOOK().
- */
-function toolbar_test_preprocess_menu(&$variables): void {
- // All the standard hook_theme variables should be populated when the
- // Toolbar module is rendering a menu.
- foreach (['menu_name', 'items', 'attributes'] as $variable) {
- $variables[$variable];
- }
-}
diff --git a/core/modules/toolbar/tests/src/FunctionalJavascript/ToolbarActiveTrailTest.php b/core/modules/toolbar/tests/src/FunctionalJavascript/ToolbarActiveTrailTest.php
index b12ce9ef54f..73f495ae850 100644
--- a/core/modules/toolbar/tests/src/FunctionalJavascript/ToolbarActiveTrailTest.php
+++ b/core/modules/toolbar/tests/src/FunctionalJavascript/ToolbarActiveTrailTest.php
@@ -5,12 +5,13 @@ declare(strict_types=1);
namespace Drupal\Tests\toolbar\FunctionalJavascript;
use Drupal\FunctionalJavascriptTests\WebDriverTestBase;
+use PHPUnit\Framework\Attributes\Group;
+use PHPUnit\Framework\Attributes\TestWith;
/**
* Tests that the active trail is maintained in the toolbar.
- *
- * @group toolbar
*/
+#[Group('toolbar')]
class ToolbarActiveTrailTest extends WebDriverTestBase {
/**
@@ -43,11 +44,10 @@ class ToolbarActiveTrailTest extends WebDriverTestBase {
* @param string $orientation
* The toolbar orientation.
*
- * @testWith ["vertical"]
- * ["horizontal"]
- *
* @throws \Behat\Mink\Exception\ElementNotFoundException
*/
+ #[TestWith(["vertical"])]
+ #[TestWith(["horizontal"])]
public function testToolbarActiveTrail(string $orientation): void {
$page = $this->getSession()->getPage();
$assert_session = $this->assertSession();
diff --git a/core/modules/toolbar/tests/src/FunctionalJavascript/ToolbarIntegrationTest.php b/core/modules/toolbar/tests/src/FunctionalJavascript/ToolbarIntegrationTest.php
index dcf0ff6d79c..639129786b3 100644
--- a/core/modules/toolbar/tests/src/FunctionalJavascript/ToolbarIntegrationTest.php
+++ b/core/modules/toolbar/tests/src/FunctionalJavascript/ToolbarIntegrationTest.php
@@ -6,12 +6,12 @@ namespace Drupal\Tests\toolbar\FunctionalJavascript;
use Behat\Mink\Element\NodeElement;
use Drupal\FunctionalJavascriptTests\WebDriverTestBase;
+use PHPUnit\Framework\Attributes\Group;
/**
* Tests the JavaScript functionality of the toolbar.
- *
- * @group toolbar
*/
+#[Group('toolbar')]
class ToolbarIntegrationTest extends WebDriverTestBase {
/**
diff --git a/core/modules/toolbar/tests/src/FunctionalJavascript/ToolbarStoredStateTest.php b/core/modules/toolbar/tests/src/FunctionalJavascript/ToolbarStoredStateTest.php
index 432dd8c8522..9fc82f8f007 100644
--- a/core/modules/toolbar/tests/src/FunctionalJavascript/ToolbarStoredStateTest.php
+++ b/core/modules/toolbar/tests/src/FunctionalJavascript/ToolbarStoredStateTest.php
@@ -6,12 +6,12 @@ namespace Drupal\Tests\toolbar\FunctionalJavascript;
use Drupal\Component\Serialization\Json;
use Drupal\FunctionalJavascriptTests\WebDriverTestBase;
+use PHPUnit\Framework\Attributes\Group;
/**
* Tests the sessionStorage state set by the toolbar.
- *
- * @group toolbar
*/
+#[Group('toolbar')]
class ToolbarStoredStateTest extends WebDriverTestBase {
/**
diff --git a/core/modules/toolbar/toolbar.module b/core/modules/toolbar/toolbar.module
index 51986310901..4bfcd89e187 100644
--- a/core/modules/toolbar/toolbar.module
+++ b/core/modules/toolbar/toolbar.module
@@ -118,17 +118,6 @@ function toolbar_menu_navigation_links(array $tree) {
}
/**
- * Implements hook_preprocess_HOOK() for HTML document templates.
- */
-function toolbar_preprocess_html(&$variables): void {
- if (!\Drupal::currentUser()->hasPermission('access toolbar')) {
- return;
- }
-
- $variables['attributes']['class'][] = 'toolbar-loading';
-}
-
-/**
* Returns the rendered subtree of each top-level toolbar link.
*
* @return array