Skip to content

Commit

Permalink
NGSTACK-816 rename setting for showing urls outside configured conten…
Browse files Browse the repository at this point in the history
…t tree root
  • Loading branch information
petarjakopec committed Aug 27, 2024
1 parent b70c2e5 commit 2157bc4
Show file tree
Hide file tree
Showing 7 changed files with 23 additions and 24 deletions.
2 changes: 1 addition & 1 deletion bundle/DependencyInjection/Configuration.php
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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'],
);
}
}
2 changes: 1 addition & 1 deletion bundle/Resources/config/default_settings.yaml
Original file line number Diff line number Diff line change
@@ -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
2 changes: 1 addition & 1 deletion bundle/Resources/config/services/tabs.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Original file line number Diff line number Diff line change
Expand Up @@ -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' %}
16 changes: 8 additions & 8 deletions bundle/Tab/LocationView/UrlsTab.php
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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'];
Expand Down Expand Up @@ -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);
Expand Down
10 changes: 5 additions & 5 deletions tests/bundle/DependencyInjection/NetgenIbexaAdminUIExtraTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ public static function provideDefaultConfigurationCases(): iterable
],
[
[
'show_external_siteaccess_urls' => false,
'show_siteaccess_urls_outside_configured_content_tree_root' => false,
],
],
];
Expand All @@ -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,
],
Expand All @@ -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,
);
}
Expand All @@ -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,
);
}
Expand Down

0 comments on commit 2157bc4

Please sign in to comment.