Loading core/modules/navigation/src/NavigationRenderer.php +19 −6 Original line number Diff line number Diff line Loading @@ -204,13 +204,26 @@ protected function getContentTop(): array { * @see hook_page_top() */ public function buildTopBar(array &$page_top): void { $page_top['top_bar']['#cache']['contexts'][] = 'user.permissions'; if ($this->currentUser->hasPermission('access navigation')) { $page_top['top_bar'] = [ '#type' => 'top_bar', '#access' => $this->currentUser->hasPermission('access navigation'), '#cache' => [ 'keys' => ['top_bar'], 'contexts' => ['user.permissions'], 'keys' => ['navigation', 'top_bar'], 'max-age' => CacheBackendInterface::CACHE_PERMANENT, ], '#lazy_builder' => ['navigation.renderer:doBuildTopBar', []], '#create_placeholder' => TRUE, ]; } } /** * Lazy builder to generate the top bar render array. */ #[TrustedCallback] public function doBuildTopBar(): array { return [ '#type' => 'top_bar', ]; } Loading core/modules/navigation/tests/src/FunctionalJavascript/PerformanceTest.php +2 −2 Original line number Diff line number Diff line Loading @@ -76,14 +76,14 @@ public function testLogin(): void { $expected = [ 'QueryCount' => 4, 'CacheGetCount' => 47, 'CacheGetCount' => 45, 'CacheGetCountByBin' => [ 'config' => 10, 'data' => 4, 'discovery' => 9, 'bootstrap' => 8, 'dynamic_page_cache' => 1, 'render' => 14, 'render' => 12, 'menu' => 1, ], 'CacheSetCount' => 2, Loading Loading
core/modules/navigation/src/NavigationRenderer.php +19 −6 Original line number Diff line number Diff line Loading @@ -204,13 +204,26 @@ protected function getContentTop(): array { * @see hook_page_top() */ public function buildTopBar(array &$page_top): void { $page_top['top_bar']['#cache']['contexts'][] = 'user.permissions'; if ($this->currentUser->hasPermission('access navigation')) { $page_top['top_bar'] = [ '#type' => 'top_bar', '#access' => $this->currentUser->hasPermission('access navigation'), '#cache' => [ 'keys' => ['top_bar'], 'contexts' => ['user.permissions'], 'keys' => ['navigation', 'top_bar'], 'max-age' => CacheBackendInterface::CACHE_PERMANENT, ], '#lazy_builder' => ['navigation.renderer:doBuildTopBar', []], '#create_placeholder' => TRUE, ]; } } /** * Lazy builder to generate the top bar render array. */ #[TrustedCallback] public function doBuildTopBar(): array { return [ '#type' => 'top_bar', ]; } Loading
core/modules/navigation/tests/src/FunctionalJavascript/PerformanceTest.php +2 −2 Original line number Diff line number Diff line Loading @@ -76,14 +76,14 @@ public function testLogin(): void { $expected = [ 'QueryCount' => 4, 'CacheGetCount' => 47, 'CacheGetCount' => 45, 'CacheGetCountByBin' => [ 'config' => 10, 'data' => 4, 'discovery' => 9, 'bootstrap' => 8, 'dynamic_page_cache' => 1, 'render' => 14, 'render' => 12, 'menu' => 1, ], 'CacheSetCount' => 2, Loading