From 260a664b5f6e7a953e27afacdf50ce87f6371696 Mon Sep 17 00:00:00 2001 From: Mehmet Korkmaz Date: Mon, 23 Jul 2018 10:20:35 +0300 Subject: [PATCH] there may be multiple fastroute cache file to delete issue fixed --- src/Cache/ClearRouteDispatcherData.php | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/src/Cache/ClearRouteDispatcherData.php b/src/Cache/ClearRouteDispatcherData.php index 1eb3037..943b29e 100644 --- a/src/Cache/ClearRouteDispatcherData.php +++ b/src/Cache/ClearRouteDispatcherData.php @@ -28,9 +28,16 @@ protected function execute(InputInterface $input, OutputInterface $output) : voi { $config = $this->container->get('config'); $routeCacheFile = $config['app']['cache_file'] ?? ''; - $unlinkResult = file_exists((string) $routeCacheFile) - ? unlink($routeCacheFile) ? 'deleted.' : 'could\'t deleted' - : 'does not exist!'; - $output->writeln('Route cache file ' .$routeCacheFile . ' ' . $unlinkResult); + if (trim((string) $routeCacheFile) !== '') { + $folder = dirname($routeCacheFile); + $files = glob($folder . '/*fastroute.cache'); + $output->writeln('Fastroute cache files under ' . $folder . ' will be deleted.'); + foreach ($files as $file) { + $unlinkResult = file_exists($file) + ? (unlink($file) === true) ? 'deleted.' : 'could\'t deleted' + : ' file does not exist'; + $output->writeln($file . ' ' . $unlinkResult); + } + } } }