improve cache clear of routes

This commit is contained in:
Simon Vieille 2021-03-24 23:05:41 +01:00
parent b9784fec69
commit c7c9a636ff

View file

@ -8,9 +8,7 @@ use App\Core\Entity\Site\Navigation;
use App\Core\Entity\Site\Node; use App\Core\Entity\Site\Node;
use App\Core\Event\EntityManager\EntityManagerEvent; use App\Core\Event\EntityManager\EntityManagerEvent;
use App\Core\EventSuscriber\EntityManagerEventSubscriber; use App\Core\EventSuscriber\EntityManagerEventSubscriber;
use Symfony\Bundle\FrameworkBundle\Console\Application; use Symfony\Component\Finder\Finder;
use Symfony\Component\Console\Input\ArrayInput;
use Symfony\Component\Console\Output\BufferedOutput;
use Symfony\Component\HttpKernel\KernelInterface; use Symfony\Component\HttpKernel\KernelInterface;
/** /**
@ -53,14 +51,14 @@ class SiteEventSubscriber extends EntityManagerEventSubscriber
protected function cleanCache() protected function cleanCache()
{ {
$application = new Application($this->kernel); $finder = new Finder();
$application->setAutoExit(false); $finder
->in($this->kernel->getCacheDir())
->name('url_*.php*')
;
$input = new ArrayInput([ foreach ($finder as $file) {
'command' => 'cache:clear', unlink((string) $file->getPathname());
]); }
$output = new BufferedOutput();
$application->run($input, $output);
} }
} }