From accb3d9741e0afbf0f074546a1ec17c32dee97a4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Edi=20Modri=C4=87?= Date: Fri, 8 Dec 2023 18:02:31 +0100 Subject: [PATCH] Provide parameters to configure default group and siteaccess name in debug toolbar --- bundle/Debug/DataCollector/LayoutUrlGenerator.php | 12 ++++++++++-- bundle/Resources/config/debug/services.yaml | 6 ++++++ 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/bundle/Debug/DataCollector/LayoutUrlGenerator.php b/bundle/Debug/DataCollector/LayoutUrlGenerator.php index 943a2a53..0bba86c4 100644 --- a/bundle/Debug/DataCollector/LayoutUrlGenerator.php +++ b/bundle/Debug/DataCollector/LayoutUrlGenerator.php @@ -16,20 +16,28 @@ final class LayoutUrlGenerator implements LayoutUrlGeneratorInterface */ private array $siteAccessGroups; + private string $siteAccessGroupName; + + private string $defaultSiteAccessName; + /** * @param array $siteAccessGroups */ public function __construct( LayoutUrlGeneratorInterface $innerGenerator, - array $siteAccessGroups + array $siteAccessGroups, + string $siteAccessGroupName, + string $defaultSiteAccessName ) { $this->innerGenerator = $innerGenerator; $this->siteAccessGroups = $siteAccessGroups; + $this->siteAccessGroupName = $siteAccessGroupName; + $this->defaultSiteAccessName = $defaultSiteAccessName; } public function generateLayoutUrl(UuidInterface $layoutId, array $parameters = []): string { - $adminSiteAccess = $this->siteAccessGroups['admin_group'][0] ?? 'admin'; + $adminSiteAccess = $this->siteAccessGroups[$this->siteAccessGroupName][0] ?? $this->defaultSiteAccessName; return $this->innerGenerator->generateLayoutUrl($layoutId, ['siteaccess' => $adminSiteAccess]); } diff --git a/bundle/Resources/config/debug/services.yaml b/bundle/Resources/config/debug/services.yaml index 0a040b44..d246139d 100644 --- a/bundle/Resources/config/debug/services.yaml +++ b/bundle/Resources/config/debug/services.yaml @@ -1,3 +1,7 @@ +parameters: + netgen_layouts.ezplatform.data_collector.site_access_group_name: 'admin_group' + netgen_layouts.ezplatform.data_collector.default_site_access_name: 'admin' + services: netgen_layouts.ezplatform.debug.data_collector.layout_url_generator: class: Netgen\Bundle\LayoutsEzPlatformBundle\Debug\DataCollector\LayoutUrlGenerator @@ -5,3 +9,5 @@ services: arguments: - "@netgen_layouts.ezplatform.debug.data_collector.layout_url_generator.inner" - "%ezpublish.siteaccess.groups%" + - "%netgen_layouts.ezplatform.data_collector.site_access_group_name%" + - "%netgen_layouts.ezplatform.data_collector.default_site_access_name%"