diff options
Diffstat (limited to 'core/modules/navigation')
3 files changed, 41 insertions, 22 deletions
diff --git a/core/modules/navigation/navigation.install b/core/modules/navigation/navigation.install index e4280b472ac2..77390203123a 100644 --- a/core/modules/navigation/navigation.install +++ b/core/modules/navigation/navigation.install @@ -22,25 +22,6 @@ function navigation_install(bool $is_syncing): void { } /** - * Implements hook_requirements(). - */ -function navigation_requirements($phase): array { - $requirements = []; - - if ($phase === 'runtime') { - if (\Drupal::moduleHandler()->moduleExists('toolbar')) { - $requirements['toolbar'] = [ - 'title' => t('Toolbar and Navigation modules are both installed'), - 'value' => t('The Navigation module is a complete replacement for the Toolbar module and disables its functionality when both modules are installed. If you are planning to continue using Navigation module, you can uninstall the Toolbar module now.'), - 'severity' => REQUIREMENT_WARNING, - ]; - } - } - - return $requirements; -} - -/** * Reorganizes the values for the logo settings. */ function navigation_update_11001(array &$sandbox): void { diff --git a/core/modules/navigation/src/Hook/NavigationRequirements.php b/core/modules/navigation/src/Hook/NavigationRequirements.php new file mode 100644 index 000000000000..ae04608bfd66 --- /dev/null +++ b/core/modules/navigation/src/Hook/NavigationRequirements.php @@ -0,0 +1,38 @@ +<?php + +declare(strict_types=1); + +namespace Drupal\navigation\Hook; + +use Drupal\Core\Extension\ModuleHandlerInterface; +use Drupal\Core\Hook\Attribute\Hook; +use Drupal\Core\StringTranslation\StringTranslationTrait; + +/** + * Requirements for the navigation module. + */ +class NavigationRequirements { + + use StringTranslationTrait; + + public function __construct( + protected readonly ModuleHandlerInterface $moduleHandler, + ) {} + + /** + * Implements hook_runtime_requirements(). + */ + #[Hook('runtime_requirements')] + public function runtime(): array { + $requirements = []; + if ($this->moduleHandler->moduleExists('toolbar')) { + $requirements['toolbar'] = [ + 'title' => $this->t('Toolbar and Navigation modules are both installed'), + 'value' => $this->t('The Navigation module is a complete replacement for the Toolbar module and disables its functionality when both modules are installed. If you are planning to continue using Navigation module, you can uninstall the Toolbar module now.'), + 'severity' => REQUIREMENT_WARNING, + ]; + } + return $requirements; + } + +} diff --git a/core/modules/navigation/tests/src/FunctionalJavascript/PerformanceTest.php b/core/modules/navigation/tests/src/FunctionalJavascript/PerformanceTest.php index 3264d769c195..2371bef31aac 100644 --- a/core/modules/navigation/tests/src/FunctionalJavascript/PerformanceTest.php +++ b/core/modules/navigation/tests/src/FunctionalJavascript/PerformanceTest.php @@ -73,14 +73,14 @@ class PerformanceTest extends PerformanceTestBase { $expected = [ 'QueryCount' => 4, - 'CacheGetCount' => 49, + 'CacheGetCount' => 48, 'CacheGetCountByBin' => [ 'config' => 11, 'data' => 4, 'discovery' => 10, 'bootstrap' => 6, 'dynamic_page_cache' => 1, - 'render' => 16, + 'render' => 15, 'menu' => 1, ], 'CacheSetCount' => 2, @@ -91,7 +91,7 @@ class PerformanceTest extends PerformanceTestBase { 'CacheTagInvalidationCount' => 0, 'CacheTagLookupQueryCount' => 14, 'ScriptCount' => 3, - 'ScriptBytes' => 215500, + 'ScriptBytes' => 213500, 'StylesheetCount' => 2, 'StylesheetBytes' => 46000, ]; |