From c26a35d23450e89e40bfd36d9e451431ed9d27d7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bartosz=20Wojda=C5=82owicz?= Date: Fri, 16 Feb 2024 12:34:13 +0100 Subject: [PATCH] OP-231 - add tagging renderers when instance of xRendererStrategyInterface, make cache per locale purge grouped in expanded tabs --- .../BitBagSyliusSuluExtension.php | 19 +++++++++++++ .../Grid/Action/invalidateSuluCache.html.twig | 27 +++++++++++-------- translations/messages.en.yaml | 2 +- 3 files changed, 36 insertions(+), 12 deletions(-) diff --git a/src/DependencyInjection/BitBagSyliusSuluExtension.php b/src/DependencyInjection/BitBagSyliusSuluExtension.php index f9577fe..2adaedc 100644 --- a/src/DependencyInjection/BitBagSyliusSuluExtension.php +++ b/src/DependencyInjection/BitBagSyliusSuluExtension.php @@ -4,6 +4,8 @@ namespace BitBag\SyliusSuluPlugin\DependencyInjection; +use BitBag\SyliusSuluPlugin\Renderer\Block\SuluBlockRenderStrategyInterface; +use BitBag\SyliusSuluPlugin\Renderer\Page\SuluPageRenderStrategyInterface; use Sylius\Bundle\CoreBundle\DependencyInjection\PrependDoctrineMigrationsTrait; use Sylius\Bundle\ResourceBundle\DependencyInjection\Extension\AbstractResourceExtension; use Symfony\Component\Config\FileLocator; @@ -21,6 +23,9 @@ public function load(array $configs, ContainerBuilder $container): void $loader = new XmlFileLoader($container, new FileLocator(__DIR__ . '/../../config')); $loader->load('services.xml'); + + $this->RegisterPageRenderers($container); + $this->RegisterBlockRenderers($container); } public function prepend(ContainerBuilder $container): void @@ -44,4 +49,18 @@ protected function getNamespacesOfMigrationsExecutedBefore(): array 'Sylius\Bundle\CoreBundle\Migrations', ]; } + + private function RegisterPageRenderers(ContainerBuilder $container): void + { + $container->registerForAutoconfiguration(SuluPageRenderStrategyInterface::class) + ->addTag('bitbag.sylius_sulu_plugin.strategy.page_renderer') + ; + } + + private function RegisterBlockRenderers(ContainerBuilder $container): void + { + $container->registerForAutoconfiguration(SuluBlockRenderStrategyInterface::class) + ->addTag('bitbag.sylius_sulu_plugin.strategy.block_renderer') + ; + } } diff --git a/templates/Admin/Grid/Action/invalidateSuluCache.html.twig b/templates/Admin/Grid/Action/invalidateSuluCache.html.twig index a4050b8..2523db1 100644 --- a/templates/Admin/Grid/Action/invalidateSuluCache.html.twig +++ b/templates/Admin/Grid/Action/invalidateSuluCache.html.twig @@ -1,17 +1,22 @@ -{% import '@SyliusUi/Macro/buttons.html.twig' as buttons %} - -{% set baseParameters = options.link.parameters %} - {% if true == data.isSuluUseLocalizedUrls %} - {% for locale in data.locales %} - {% set parameters = baseParameters|merge({'locale': locale.code})%} - {% set path = options.link.url|default(path(options.link.route, parameters)) %} + {% else %} + {% import '@SyliusUi/Macro/buttons.html.twig' as buttons %} + {% set path = options.link.url|default(path(options.link.route, options.link.parameters)) %} {{ buttons.default(path, action.label , null, action.icon, 'blue') }} -{% endif %} - +{% endif%} diff --git a/translations/messages.en.yaml b/translations/messages.en.yaml index 18e7fc9..7252154 100644 --- a/translations/messages.en.yaml +++ b/translations/messages.en.yaml @@ -1,6 +1,6 @@ bitbag: sulu_plugin: - purge_channel_cache: Purg sulu cache + purge_channel_cache: Purge sulu cache purge_channel_cache_en_us: Purge sulu cache en_us purge_channel_cache_pl_pl: Purge sulu cache pl_pl use_localized_url: Use localized urls