diff --git a/bundle/Debug/DataCollector/LayoutUrlGenerator.php b/bundle/Debug/DataCollector/LayoutUrlGenerator.php new file mode 100644 index 00000000..3d32ff9c --- /dev/null +++ b/bundle/Debug/DataCollector/LayoutUrlGenerator.php @@ -0,0 +1,36 @@ + + */ + private array $siteAccessGroups; + + /** + * @param array $siteAccessGroups + */ + public function __construct( + LayoutUrlGeneratorInterface $innerGenerator, + array $siteAccessGroups, + ) { + $this->innerGenerator = $innerGenerator; + $this->siteAccessGroups = $siteAccessGroups; + } + + public function generateLayoutUrl(UuidInterface $layoutId, array $parameters = []): string + { + $adminSiteAccess = $this->siteAccessGroups['admin_group'][0] ?? 'admin'; + + return $this->innerGenerator->generateLayoutUrl($layoutId, ['siteaccess' => $adminSiteAccess]); + } +} diff --git a/bundle/DependencyInjection/NetgenLayoutsEzPlatformExtension.php b/bundle/DependencyInjection/NetgenLayoutsEzPlatformExtension.php index 5895549c..05abf620 100644 --- a/bundle/DependencyInjection/NetgenLayoutsEzPlatformExtension.php +++ b/bundle/DependencyInjection/NetgenLayoutsEzPlatformExtension.php @@ -62,6 +62,10 @@ public function load(array $configs, ContainerBuilder $container): void $loader->load('eztags/services.yaml'); } + if (array_key_exists('NetgenLayoutsDebugBundle', $activatedBundles)) { + $loader->load('debug/services.yaml'); + } + $loader->load( // Nameable interface for field types does not exist in eZ Platform v3 interface_exists(Nameable::class) ? diff --git a/bundle/Resources/config/debug/services.yaml b/bundle/Resources/config/debug/services.yaml new file mode 100644 index 00000000..f7b8e17f --- /dev/null +++ b/bundle/Resources/config/debug/services.yaml @@ -0,0 +1,7 @@ +services: + netgen_layouts.ezplatform.debug.data_collector.layout_url_generator: + class: Netgen\Bundle\LayoutsEzPlatformBundle\Debug\DataCollector\LayoutUrlGenerator + decorates: netgen_layouts.debug.data_collector.layout_url_generator + arguments: + - "@.inner" + - "%ezpublish.siteaccess.groups%" diff --git a/composer.json b/composer.json index c7777f30..07eb380b 100644 --- a/composer.json +++ b/composer.json @@ -10,7 +10,7 @@ } ], "require": { - "netgen/layouts-core": "~1.4.6", + "netgen/layouts-core": "~1.4.9", "netgen/content-browser-ezplatform": "^1.4", "ezsystems/ezplatform-admin-ui": "^1.5 || ^2.3", "ezsystems/ezplatform-http-cache": "^1.0 || ^2.3"