Skip to content

Commit

Permalink
OP-231 - add tagging renderers when instance of xRendererStrategyInte…
Browse files Browse the repository at this point in the history
…rface, make cache per locale purge grouped in expanded tabs
  • Loading branch information
BartoszWojdalowicz committed Feb 16, 2024
1 parent d0b4b62 commit c26a35d
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 12 deletions.
19 changes: 19 additions & 0 deletions src/DependencyInjection/BitBagSyliusSuluExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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
Expand All @@ -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')
;
}
}
27 changes: 16 additions & 11 deletions templates/Admin/Grid/Action/invalidateSuluCache.html.twig
Original file line number Diff line number Diff line change
@@ -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)) %}
<div class="ui labeled icon floating dropdown link button">
<i class="trash icon"></i>
<span class="text">{{ action.label|trans }}</span>
<div class="menu">
{% set baseParameters = options.link.parameters %}

{% for locale in data.locales %}
{% set parameters = baseParameters|merge({'locale': locale.code})%}
{% set path = options.link.url|default(path(options.link.route, parameters)) %}

{{ buttons.default(path, action.label ~ '_' ~locale.code|lower , null, action.icon, 'blue') }}
{% endfor %}
<a class="item" href="{{ path }}"><i class="trash icon test"></i> {{ locale.code}} </a>
{% endfor %}
</div>
</div>
{% 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%}
2 changes: 1 addition & 1 deletion translations/messages.en.yaml
Original file line number Diff line number Diff line change
@@ -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
Expand Down

0 comments on commit c26a35d

Please sign in to comment.