Skip to content

Commit

Permalink
Provide parameters to configure default group and siteaccess name in …
Browse files Browse the repository at this point in the history
…debug toolbar
  • Loading branch information
emodric committed Dec 8, 2023
1 parent 31cbf89 commit accb3d9
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 2 deletions.
12 changes: 10 additions & 2 deletions bundle/Debug/DataCollector/LayoutUrlGenerator.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,20 +16,28 @@ final class LayoutUrlGenerator implements LayoutUrlGeneratorInterface
*/
private array $siteAccessGroups;

private string $siteAccessGroupName;

private string $defaultSiteAccessName;

/**
* @param array<string, string[]> $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]);
}
Expand Down
6 changes: 6 additions & 0 deletions bundle/Resources/config/debug/services.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,13 @@
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
decorates: netgen_layouts.debug.data_collector.layout_url_generator
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%"

0 comments on commit accb3d9

Please sign in to comment.