From 4432406876261e2f74d6f01fe5ddea425c7f5ebe Mon Sep 17 00:00:00 2001 From: Simon Vieille Date: Thu, 25 Mar 2021 11:59:47 +0100 Subject: [PATCH] add symfony cache manager --- core/Cache/SymfonyCacheManager.php | 51 ++++++++++++++++++++++++++++++ 1 file changed, 51 insertions(+) create mode 100644 core/Cache/SymfonyCacheManager.php diff --git a/core/Cache/SymfonyCacheManager.php b/core/Cache/SymfonyCacheManager.php new file mode 100644 index 0000000..da72bad --- /dev/null +++ b/core/Cache/SymfonyCacheManager.php @@ -0,0 +1,51 @@ + + */ +class SymfonyCacheManager +{ + protected KernelInterface $kernel; + + public function __construct(KernelInterface $kernel) + { + $this->kernel = $kernel; + } + + public function cleanRouting() + { + $finder = new Finder(); + $finder + ->in($this->kernel->getCacheDir()) + ->depth('== 0') + ->name('url_*.php*') + ; + + foreach ($finder as $file) { + unlink((string) $file->getPathname()); + } + } + + public function cleanAll() + { + $application = new Application($this->kernel); + $application->setAutoExit(false); + + $input = new ArrayInput([ + 'command' => 'cache:clear', + ]); + + $output = new BufferedOutput(); + $application->run($input, $output); + } +}