From 2157bc482c86a3aa8263ec1a563c7624206bf2cd Mon Sep 17 00:00:00 2001 From: Petar Jakopec Date: Tue, 27 Aug 2024 10:41:03 +0200 Subject: [PATCH] NGSTACK-816 rename setting for showing urls outside configured content tree root --- bundle/DependencyInjection/Configuration.php | 2 +- .../NetgenIbexaAdminUIExtraExtension.php | 8 ++++---- bundle/Resources/config/default_settings.yaml | 2 +- bundle/Resources/config/services/tabs.yaml | 2 +- .../themes/ngadmin/content/tab/urls.html.twig | 7 +++---- bundle/Tab/LocationView/UrlsTab.php | 16 ++++++++-------- .../NetgenIbexaAdminUIExtraTest.php | 10 +++++----- 7 files changed, 23 insertions(+), 24 deletions(-) diff --git a/bundle/DependencyInjection/Configuration.php b/bundle/DependencyInjection/Configuration.php index 498c248..d92f5d7 100644 --- a/bundle/DependencyInjection/Configuration.php +++ b/bundle/DependencyInjection/Configuration.php @@ -34,7 +34,7 @@ private function addShowExternalSiteaccessUrls(ArrayNodeDefinition $nodeDefiniti ->treatTrueLike(['enabled' => true]) ->treatNullLike(['enabled' => false]) ->children() - ->booleanNode('show_external_siteaccess_urls') + ->booleanNode('show_siteaccess_urls_outside_configured_content_tree_root') ->defaultFalse() ->end() ?->end(); diff --git a/bundle/DependencyInjection/NetgenIbexaAdminUIExtraExtension.php b/bundle/DependencyInjection/NetgenIbexaAdminUIExtraExtension.php index 50fdcd9..4cf1657 100644 --- a/bundle/DependencyInjection/NetgenIbexaAdminUIExtraExtension.php +++ b/bundle/DependencyInjection/NetgenIbexaAdminUIExtraExtension.php @@ -67,16 +67,16 @@ private function processExtensionConfiguration(array $configs, ContainerBuilder $configuration = $this->getConfiguration($configs, $container); $configuration = $this->processConfiguration($configuration, $configs); - $this->processShowExternalSiteaccessUrlsConfiguration($configuration, $container); + $this->processShowSiteaccessOutsideConfiguredContentTreeRootConfiguration($configuration, $container); } - private function processShowExternalSiteaccessUrlsConfiguration( + private function processShowSiteaccessOutsideConfiguredContentTreeRootConfiguration( array $configuration, ContainerBuilder $container, ): void { $container->setParameter( - 'netgen_ibexa_admin_ui_extra.show_external_siteaccess_urls', - $configuration['show_external_siteaccess_urls'], + 'netgen_ibexa_admin_ui_extra.show_siteaccess_urls_outside_configured_content_tree_root', + $configuration['show_siteaccess_urls_outside_configured_content_tree_root'], ); } } diff --git a/bundle/Resources/config/default_settings.yaml b/bundle/Resources/config/default_settings.yaml index 258de19..6ebf6a0 100644 --- a/bundle/Resources/config/default_settings.yaml +++ b/bundle/Resources/config/default_settings.yaml @@ -1,2 +1,2 @@ parameters: - netgen_ibexa_admin_ui_extra.show_external_siteaccess_urls: false + netgen_ibexa_admin_ui_extra.show_siteaccess_urls_outside_configured_content_tree_root: false diff --git a/bundle/Resources/config/services/tabs.yaml b/bundle/Resources/config/services/tabs.yaml index 8b10cbb..373c614 100644 --- a/bundle/Resources/config/services/tabs.yaml +++ b/bundle/Resources/config/services/tabs.yaml @@ -18,7 +18,7 @@ services: - '@router' - '@ibexa.config.resolver' - '%ibexa.site_access.list%' - - '%netgen_ibexa_admin_ui_extra.show_external_siteaccess_urls%' + - '%netgen_ibexa_admin_ui_extra.show_siteaccess_urls_outside_configured_content_tree_root%' - '@twig' - '@translator' - '@event_dispatcher' diff --git a/bundle/Resources/views/themes/ngadmin/content/tab/urls.html.twig b/bundle/Resources/views/themes/ngadmin/content/tab/urls.html.twig index ebb7403..fa9cb18 100644 --- a/bundle/Resources/views/themes/ngadmin/content/tab/urls.html.twig +++ b/bundle/Resources/views/themes/ngadmin/content/tab/urls.html.twig @@ -3,17 +3,16 @@ {% include '@ibexadesign/content/tab/url/siteaccess_urls_table.html.twig' with { headline:'tab.urls.siteaccess.headline.siteaccess_urls'|trans|desc ('Siteaccess URLs'), - siteaccess_urls: content_tree_urls, + siteaccess_urls: siteaccess_urls, } only %} -{% if show_external_urls %} +{% if show_siteaccess_urls_outside_configured_content_tree_root %} {% include '@ibexadesign/content/tab/url/siteaccess_urls_table.html.twig' with { headline: 'tab.urls.siteaccess.headline.siteaccess_urls.outside_configured_content_tree_root'|trans|desc ('Siteaccess URLs outside of the configured Content tree root'), - siteaccess_urls: external_urls, + siteaccess_urls: siteaccess_urls_outside_configured_content_tree_root, } only %} {% endif %} - {% include '@admin/content/tab/urls.html.twig' %} diff --git a/bundle/Tab/LocationView/UrlsTab.php b/bundle/Tab/LocationView/UrlsTab.php index 6109bb6..819ec6a 100644 --- a/bundle/Tab/LocationView/UrlsTab.php +++ b/bundle/Tab/LocationView/UrlsTab.php @@ -27,7 +27,7 @@ public function __construct( private readonly RouterInterface $router, private readonly ConfigResolverInterface $configResolver, private readonly array $siteaccessList, - private readonly bool $showExternalSiteaccessUrls, + private readonly bool $showSiteaccessUrlsOutsideConfiguredContentTreeRoot, Environment $twig, TranslatorInterface $translator, EventDispatcherInterface $eventDispatcher, @@ -57,8 +57,8 @@ public function getTemplate(): string public function getTemplateParameters(array $contextParameters = []): array { - $contentTreeUrls = []; - $externalUrls = []; + $siteaccessUrls = []; + $siteaccessUrlsOutsideConfiguredContentTreeRoot = []; /** @var \Ibexa\Contracts\Core\Repository\Values\Content\Location $location */ $location = $contextParameters['location']; @@ -89,16 +89,16 @@ public function getTemplateParameters(array $contextParameters = []): array // checks if the url is inside configured siteaccess content tree if ($locationIdIndex !== false && $rootLocationIdIndex !== false && $rootLocationIdIndex <= $locationIdIndex) { - $contentTreeUrls[$siteaccess] = $url; + $siteaccessUrls[$siteaccess] = $url; } else { - $externalUrls[$siteaccess] = $url; + $siteaccessUrlsOutsideConfiguredContentTreeRoot[$siteaccess] = $url; } } $parameters = [ - 'content_tree_urls' => $contentTreeUrls, - 'external_urls' => $externalUrls, - 'show_external_urls' => $this->showExternalSiteaccessUrls, + 'siteaccess_urls' => $siteaccessUrls, + 'siteaccess_urls_outside_configured_content_tree_root' => $siteaccessUrlsOutsideConfiguredContentTreeRoot, + 'show_siteaccess_urls_outside_configured_content_tree_root' => $this->showSiteaccessUrlsOutsideConfiguredContentTreeRoot, ]; $parentParameters = $this->inner->getTemplateParameters($contextParameters); diff --git a/tests/bundle/DependencyInjection/NetgenIbexaAdminUIExtraTest.php b/tests/bundle/DependencyInjection/NetgenIbexaAdminUIExtraTest.php index 15ee1ff..7b3a64e 100644 --- a/tests/bundle/DependencyInjection/NetgenIbexaAdminUIExtraTest.php +++ b/tests/bundle/DependencyInjection/NetgenIbexaAdminUIExtraTest.php @@ -24,7 +24,7 @@ public static function provideDefaultConfigurationCases(): iterable ], [ [ - 'show_external_siteaccess_urls' => false, + 'show_siteaccess_urls_outside_configured_content_tree_root' => false, ], ], ]; @@ -35,13 +35,13 @@ public static function provideShowExternalSiteaccessUrlsConfigurationCases(): it return [ [ [ - 'show_external_siteaccess_urls' => false, + 'show_siteaccess_urls_outside_configured_content_tree_root' => false, ], false, ], [ [ - 'show_external_siteaccess_urls' => true, + 'show_siteaccess_urls_outside_configured_content_tree_root' => true, ], true, ], @@ -56,7 +56,7 @@ public function testDefaultConfiguration(array $configuration): void $this->load($configuration); $this->assertContainerBuilderHasParameter( - 'netgen_ibexa_admin_ui_extra.show_external_siteaccess_urls', + 'netgen_ibexa_admin_ui_extra.show_siteaccess_urls_outside_configured_content_tree_root', false, ); } @@ -69,7 +69,7 @@ public function testShowExternalSiteaccessUrlsConfiguration(array $configuration $this->load($configuration); $this->assertContainerBuilderHasParameter( - 'netgen_ibexa_admin_ui_extra.show_external_siteaccess_urls', + 'netgen_ibexa_admin_ui_extra.show_siteaccess_urls_outside_configured_content_tree_root', $expectedParameterValue, ); }