From 630de86e160ec591f1e4f0280906d67e8e1dcc4b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pablo=20L=C3=B3pez=20//=20plopesc?= <plopesc@gmail.com> Date: Tue, 1 Apr 2025 10:39:07 +0200 Subject: [PATCH 1/2] Issue #3516558: Settings is not a valid render array in navigation module --- .../navigation/layouts/navigation.html.twig | 15 ++++++++------- .../modules/navigation/src/NavigationRenderer.php | 8 ++++---- 2 files changed, 12 insertions(+), 11 deletions(-) diff --git a/core/modules/navigation/layouts/navigation.html.twig b/core/modules/navigation/layouts/navigation.html.twig index 699d14f72c02..d2c001cf160a 100644 --- a/core/modules/navigation/layouts/navigation.html.twig +++ b/core/modules/navigation/layouts/navigation.html.twig @@ -6,17 +6,18 @@ * Available variables: * - content: The content for this layout. * - attributes: HTML attributes for the layout <div>. - * - content.settings.hide_logo: Whether to hide the logo. - * - content.settings.logo_path: The path to the logo image if logo_managed + * - content.#settings.hide_logo: Whether to hide the logo. + * - content.#settings.logo_path: The path to the logo image if logo_managed * in navigation.settings configuration has been set. - * - content.settings.logo_width: The width of the logo image. Available if + * - content.#settings.logo_width: The width of the logo image. Available if * logo_path points to a valid image file. - * - content.settings.logo_height: The height of the logo image. Available if + * - content.#settings.logo_height: The height of the logo image. Available if * logo_path points to a valid image file. * @ingroup themeable */ #} {% set control_bar_attributes = create_attribute() %} +{% set settings = content['#settings'] %} <div {{ control_bar_attributes.addClass('admin-toolbar-control-bar').setAttribute('data-drupal-admin-styles', '') }}> <div class="admin-toolbar-control-bar__content"> @@ -45,10 +46,10 @@ <h3 id="{{ title_menu }}" class="visually-hidden">{{ 'Administrative toolbar content'|t }}</h3> {# @todo - Needs to be placed here so we can have the header footer on mobile. #} <div class="admin-toolbar__header"> - {% if not content.settings.hide_logo %} + {% if not settings.hide_logo %} <a class="admin-toolbar__logo" href="{{ path('<front>') }}"> - {% if content.settings.logo_path is not null %} - <img alt="{{ 'Navigation logo'|t }}" src="{{ content.settings.logo_path }}" loading="eager" width="{{ content.settings.logo_width|default(40) }}" height="{{ content.settings.logo_height|default(40) }}"> + {% if settings.logo_path is not null %} + <img alt="{{ 'Navigation logo'|t }}" src="{{ settings.logo_path }}" loading="eager" width="{{ settings.logo_width|default(40) }}" height="{{ settings.logo_height|default(40) }}"> {% else %} {% include '@navigation/logo.svg.twig' with { label: 'Navigation logo'|t diff --git a/core/modules/navigation/src/NavigationRenderer.php b/core/modules/navigation/src/NavigationRenderer.php index dfb9dd7cc779..c30ed19c8c19 100644 --- a/core/modules/navigation/src/NavigationRenderer.php +++ b/core/modules/navigation/src/NavigationRenderer.php @@ -134,7 +134,7 @@ public function doBuildNavigation(): array { $asset_url = $module_path . '/assets/fonts/inter-var.woff2'; $defaults = [ - 'settings' => ['hide_logo' => $logo_provider === self::LOGO_PROVIDER_HIDE], + '#settings' => ['hide_logo' => $logo_provider === self::LOGO_PROVIDER_HIDE], '#attached' => [ 'html_head_link' => [ [ @@ -157,10 +157,10 @@ public function doBuildNavigation(): array { if (!empty($logo_path) && is_file($logo_path)) { $logo_managed_url = $this->fileUrlGenerator->generateAbsoluteString($logo_path); $image = $this->imageFactory->get($logo_path); - $build[0]['settings']['logo_path'] = $logo_managed_url; + $build[0]['#settings']['logo_path'] = $logo_managed_url; if ($image->isValid()) { - $build[0]['settings']['logo_width'] = $image->getWidth(); - $build[0]['settings']['logo_height'] = $image->getHeight(); + $build[0]['#settings']['logo_width'] = $image->getWidth(); + $build[0]['#settings']['logo_height'] = $image->getHeight(); } } } -- GitLab From 9b30de560cfa8b4ed0f6b99876ab1c71c0d26c08 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pablo=20L=C3=B3pez=20//=20plopesc?= <plopesc@gmail.com> Date: Sat, 5 Apr 2025 08:51:52 +0200 Subject: [PATCH 2/2] Issue #3516558: Use the existing settings property --- .../navigation/layouts/navigation.html.twig | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/core/modules/navigation/layouts/navigation.html.twig b/core/modules/navigation/layouts/navigation.html.twig index d2c001cf160a..ccbcf7601d25 100644 --- a/core/modules/navigation/layouts/navigation.html.twig +++ b/core/modules/navigation/layouts/navigation.html.twig @@ -6,18 +6,18 @@ * Available variables: * - content: The content for this layout. * - attributes: HTML attributes for the layout <div>. - * - content.#settings.hide_logo: Whether to hide the logo. - * - content.#settings.logo_path: The path to the logo image if logo_managed - * in navigation.settings configuration has been set. - * - content.#settings.logo_width: The width of the logo image. Available if - * logo_path points to a valid image file. - * - content.#settings.logo_height: The height of the logo image. Available if - * logo_path points to a valid image file. + * - settings: layout settings. The following are related to the logo: + * - hide_logo: Whether to hide the logo. + * - logo_path: The path to the logo image if logo_managed + * in navigation.settings configuration has been set. + * - logo_width: The width of the logo image. Available if + * logo_path points to a valid image file. + * - settings.logo_height: The height of the logo image. Available if + * logo_path points to a valid image file. * @ingroup themeable */ #} {% set control_bar_attributes = create_attribute() %} -{% set settings = content['#settings'] %} <div {{ control_bar_attributes.addClass('admin-toolbar-control-bar').setAttribute('data-drupal-admin-styles', '') }}> <div class="admin-toolbar-control-bar__content"> -- GitLab