Adding automatic cache clearing in case of changed translation files
This commit is contained in:
parent
ef297fa8e1
commit
38e45f5d8f
1 changed files with 32 additions and 0 deletions
32
Classes/Package.php
Normal file
32
Classes/Package.php
Normal file
|
@ -0,0 +1,32 @@
|
|||
<?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();
|
||||
}
|
||||
}
|
||||
);
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue