From c7c9a636ff402056e128bc5e87131d8e18edc5d3 Mon Sep 17 00:00:00 2001 From: Simon Vieille Date: Wed, 24 Mar 2021 23:05:41 +0100 Subject: [PATCH] improve cache clear of routes --- .../Site/SiteEventSubscriber.php | 20 +++++++++---------- 1 file changed, 9 insertions(+), 11 deletions(-) diff --git a/core/EventSuscriber/Site/SiteEventSubscriber.php b/core/EventSuscriber/Site/SiteEventSubscriber.php index cf95a5d..5e8c562 100644 --- a/core/EventSuscriber/Site/SiteEventSubscriber.php +++ b/core/EventSuscriber/Site/SiteEventSubscriber.php @@ -8,9 +8,7 @@ use App\Core\Entity\Site\Navigation; use App\Core\Entity\Site\Node; use App\Core\Event\EntityManager\EntityManagerEvent; use App\Core\EventSuscriber\EntityManagerEventSubscriber; -use Symfony\Bundle\FrameworkBundle\Console\Application; -use Symfony\Component\Console\Input\ArrayInput; -use Symfony\Component\Console\Output\BufferedOutput; +use Symfony\Component\Finder\Finder; use Symfony\Component\HttpKernel\KernelInterface; /** @@ -53,14 +51,14 @@ class SiteEventSubscriber extends EntityManagerEventSubscriber protected function cleanCache() { - $application = new Application($this->kernel); - $application->setAutoExit(false); + $finder = new Finder(); + $finder + ->in($this->kernel->getCacheDir()) + ->name('url_*.php*') + ; - $input = new ArrayInput([ - 'command' => 'cache:clear', - ]); - - $output = new BufferedOutput(); - $application->run($input, $output); + foreach ($finder as $file) { + unlink((string) $file->getPathname()); + } } }