*/ class SiteEventSubscriber extends EntityManagerEventSubscriber { protected KernelInterface $kernel; public function __construct(KernelInterface $kernel) { $this->kernel = $kernel; } public function support(EntityInterface $entity) { return $entity instanceof Node || $entity instanceof Menu || $entity instanceof Navigation; } public function onUpdate(EntityManagerEvent $event) { if (!$this->support($event->getEntity())) { return; } $this->cleanCache(); } public function onCreate(EntityManagerEvent $event) { return $this->onUpdate($event); } public function onDelete(EntityManagerEvent $event) { return $this->onUpdate($event); } protected function cleanCache() { $application = new Application($this->kernel); $application->setAutoExit(false); $input = new ArrayInput([ 'command' => 'cache:clear', ]); $output = new BufferedOutput(); $application->run($input, $output); } }