src/EventListener/DatabaseUpdateListener.php line 16
<?php
namespace App\EventListener;
use Doctrine\Persistence\Event\LifecycleEventArgs;
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
class DatabaseUpdateListener implements EventSubscriberInterface
{
public function flushCache(): void
{
// @todo: change path/logic
$command = 'php ' . $_ENV['TYPO3_PATH'] . 'vendor/bin/typo3cms cache:flush';
shell_exec($command);
}
public function postPersist(LifecycleEventArgs $args): void
{
$this->flushCache();
}
public function postUpdate(LifecycleEventArgs $args): void
{
$this->flushCache();
}
public static function getSubscribedEvents(): array
{
return [
'doctrine.postPersist' => 'postPersist',
'doctrine.postUpdate' => 'postPersist',
];
}
}