diff --git a/bundles/LayoutsDebugBundle/DataCollector/LayoutUrlGenerator.php b/bundles/LayoutsDebugBundle/DataCollector/LayoutUrlGenerator.php new file mode 100644 index 000000000..20fb09d0e --- /dev/null +++ b/bundles/LayoutsDebugBundle/DataCollector/LayoutUrlGenerator.php @@ -0,0 +1,31 @@ +urlGenerator = $urlGenerator; + $this->isDebug = $isDebug; + } + + public function generateLayoutUrl(UuidInterface $layoutId, array $parameters = []): string + { + return $this->urlGenerator->generate( + $this->isDebug ? 'nglayouts_dev_app' : 'nglayouts_app', + ['_fragment' => sprintf('layout/%s', $layoutId->toString())] + $parameters, + ); + } +} diff --git a/bundles/LayoutsDebugBundle/DataCollector/LayoutUrlGeneratorInterface.php b/bundles/LayoutsDebugBundle/DataCollector/LayoutUrlGeneratorInterface.php new file mode 100644 index 000000000..17835caa4 --- /dev/null +++ b/bundles/LayoutsDebugBundle/DataCollector/LayoutUrlGeneratorInterface.php @@ -0,0 +1,15 @@ + $parameters + */ + public function generateLayoutUrl(UuidInterface $layoutId, array $parameters = []): string; +} diff --git a/bundles/LayoutsDebugBundle/DataCollector/LayoutsDataCollector.php b/bundles/LayoutsDebugBundle/DataCollector/LayoutsDataCollector.php index 0c2a254d3..ee02873ab 100644 --- a/bundles/LayoutsDebugBundle/DataCollector/LayoutsDataCollector.php +++ b/bundles/LayoutsDebugBundle/DataCollector/LayoutsDataCollector.php @@ -27,6 +27,8 @@ final class LayoutsDataCollector extends DataCollector private GlobalVariable $globalVariable; + private LayoutUrlGeneratorInterface $layoutUrlGenerator; + private Environment $twig; /** @@ -34,10 +36,16 @@ final class LayoutsDataCollector extends DataCollector */ private array $layoutCache = []; - public function __construct(LayoutHandler $layoutHandler, GlobalVariable $globalVariable, Environment $twig, string $edition) - { + public function __construct( + LayoutHandler $layoutHandler, + GlobalVariable $globalVariable, + LayoutUrlGeneratorInterface $layoutUrlGenerator, + Environment $twig, + string $edition + ) { $this->layoutHandler = $layoutHandler; $this->globalVariable = $globalVariable; + $this->layoutUrlGenerator = $layoutUrlGenerator; $this->twig = $twig; $coreVersion = PrettyVersions::getVersion('netgen/layouts-core')->getPrettyVersion(); @@ -90,6 +98,7 @@ public function collectLayout(LayoutViewInterface $layoutView): void $this->data['layout'] = [ 'id' => $layout->getId()->toString(), + 'path' => $this->layoutUrlGenerator->generateLayoutUrl($layout->getId()), 'name' => $layout->getName(), 'type' => $layout->getLayoutType()->getName(), 'context' => $layoutView->getContext(), @@ -148,6 +157,7 @@ public function collectBlockView(BlockViewInterface $blockView): void 'id' => $block->getId()->toString(), 'name' => $block->getName(), 'layout_id' => $layoutId, + 'layout_path' => $this->layoutUrlGenerator->generateLayoutUrl($block->getLayoutId()), 'layout_name' => $this->layoutCache[$layoutId]->name, 'definition' => $blockDefinition->getName(), 'view_type' => $blockDefinition->hasViewType($block->getViewType(), $block) ? diff --git a/bundles/LayoutsDebugBundle/Resources/config/services.yaml b/bundles/LayoutsDebugBundle/Resources/config/services.yaml index c10c39f51..29f01cd71 100644 --- a/bundles/LayoutsDebugBundle/Resources/config/services.yaml +++ b/bundles/LayoutsDebugBundle/Resources/config/services.yaml @@ -2,11 +2,18 @@ parameters: netgen_layouts.debug.block_collector.enabled_contexts: ['default'] services: + netgen_layouts.debug.data_collector.layout_url_generator: + class: Netgen\Bundle\LayoutsDebugBundle\DataCollector\LayoutUrlGenerator + arguments: + - "@router" + - "%netgen_layouts.debug%" + netgen_layouts.debug.data_collector: class: Netgen\Bundle\LayoutsDebugBundle\DataCollector\LayoutsDataCollector arguments: - "@netgen_layouts.persistence.layout.handler" - "@netgen_layouts.templating.global_variable" + - "@netgen_layouts.debug.data_collector.layout_url_generator" - "@twig" - "%netgen_layouts.edition%" tags: diff --git a/bundles/LayoutsDebugBundle/Resources/views/data_collector/nglayouts.html.twig b/bundles/LayoutsDebugBundle/Resources/views/data_collector/nglayouts.html.twig index a16c78862..e27c220b5 100644 --- a/bundles/LayoutsDebugBundle/Resources/views/data_collector/nglayouts.html.twig +++ b/bundles/LayoutsDebugBundle/Resources/views/data_collector/nglayouts.html.twig @@ -1,8 +1,6 @@ {% extends '@WebProfiler/Profiler/layout.html.twig' %} {% block toolbar %} - {% import '@NetgenLayoutsAdmin/admin/macros.html.twig' as macros %} - {% set layout = collector.data.layout %} {% set rule = collector.data.rule %} @@ -30,7 +28,7 @@ Resolved layout - + {{ layout.name }} @@ -96,8 +94,6 @@ {% endblock %} {% block panel %} - {% import '@NetgenLayoutsAdmin/admin/macros.html.twig' as macros %} - {% set layout = collector.data.layout %} {% set rule = collector.data.rule %} {% set blocks = collector.data.blocks %} @@ -116,7 +112,7 @@
- + {{ layout.name }} @@ -238,7 +234,11 @@ {% for block in blocks %} {{ block.id }} - {{ block.layout_name }} + + + {{ block.layout_name }} + + {% if block.name is not empty %}