Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion src/Config/TokenCacheManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ public function setCache(CacheInterface $cache): void
public function getToken(callable $getToken, bool $useCache = true): string
{
if (!$useCache) {
$this->cache->delete(self::CACHE_KEY);
$this->clearCache();
}

$token = $this->cache->get(self::CACHE_KEY, $getToken);
Expand All @@ -41,4 +41,9 @@ public function getToken(callable $getToken, bool $useCache = true): string

return (string) $token;
}

public function clearCache(): void
{
$this->cache->delete(self::CACHE_KEY);
}
}
3 changes: 3 additions & 0 deletions src/Controller/AdminGallyController.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@

use Gally\Sdk\Service\StructureSynchonizer;
use Gally\SyliusPlugin\Config\ConfigManager;
use Gally\SyliusPlugin\Config\TokenCacheManager;
use Gally\SyliusPlugin\Entity\GallyConfiguration;
use Gally\SyliusPlugin\Form\Type\GallyConfigurationType;
use Gally\SyliusPlugin\Form\Type\SyncSourceFieldsType;
Expand Down Expand Up @@ -45,6 +46,7 @@ public function __construct(
protected ConfigManager $configManager,
\IteratorAggregate $providers,
private TranslatorInterface $translator,
private TokenCacheManager $tokenCacheManager,
) {
/** @var ProviderInterface[] $providersArray */
$providersArray = iterator_to_array($providers);
Expand All @@ -63,6 +65,7 @@ public function renderGallyConfigForm(Request $request): Response

$this->gallyConfigurationRepository->add($gallyConfiguration);
$this->addFlash('success', $this->translator->trans('gally_sylius.ui.configuration_saved'));
$this->tokenCacheManager->clearCache();
}

return $this->render('@GallySyliusPlugin/admin/gally/index.html.twig', [
Expand Down
1 change: 1 addition & 0 deletions src/Resources/config/services.xml
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
<argument type="service" id="Gally\SyliusPlugin\Config\ConfigManager" />
<argument type="tagged_iterator" tag="gally.dataprovider" index-by="entity"/>
<argument type="service" id="translator" />
<argument type="service" id="Gally\SyliusPlugin\Config\TokenCacheManager" />
<call method="setContainer">
<argument type="service" id="service_container" />
</call>
Expand Down