DigiComp.FlowTranslationEnd.../Classes/Package.php
Ferdinand Kuhl 38e45f5d8f
All checks were successful
ci/woodpecker/push/code-style Pipeline was successful
ci/woodpecker/push/functional-tests Pipeline was successful
Adding automatic cache clearing in case of changed translation files
2023-08-08 14:30:48 +02:00

32 lines
988 B
PHP

<?php
declare(strict_types=1);
namespace DigiComp\FlowTranslationEndpoint;
use Neos\Flow\Cache\CacheManager;
use Neos\Flow\Core\Bootstrap;
use Neos\Flow\Monitor\FileMonitor;
class Package extends \Neos\Flow\Package\Package
{
public function boot(Bootstrap $bootstrap)
{
parent::boot($bootstrap);
$dispatcher = $bootstrap->getSignalSlotDispatcher();
$dispatcher->connect(
FileMonitor::class,
'filesHaveChanged',
static function ($fileMonitorId, $changedFiles) use ($bootstrap) {
if ($fileMonitorId !== 'Flow_TranslationFiles') {
return;
}
if ($changedFiles !== []) {
$cacheManager = $bootstrap->getObjectManager()->get(CacheManager::class);
$cache = $cacheManager->getCache('DigiComp_FlowTranslationEndpoint_Responses');
$cache->flush();
}
}
);
}
}