diff --git a/src/Extender.php b/src/Extender.php index 84e8a4f..186f321 100644 --- a/src/Extender.php +++ b/src/Extender.php @@ -89,17 +89,20 @@ public function processPackages(Event $event) if (file_exists($configFile)) { unlink($configFile); - $this->io->write('Removing config cache file:' . $configFile); + $this->io->write('Removing config cache file:'); + $this->io->write($configFile); } if (file_exists($servicesFile)) { unlink($servicesFile); - $this->io->write('Removing services cache file:' . $servicesFile); + $this->io->write('Removing packages services cache file:'); + $this->io->write($servicesFile); } if (file_exists($servicesUninstallFile)) { unlink($servicesUninstallFile); - $this->io->write('Removing services cache file:' . $servicesUninstallFile); + $this->io->write('Removing packages services cache file:'); + $this->io->write($servicesUninstallFile); } if ($configData = $extenderManager->getConfigData()) { @@ -107,7 +110,8 @@ public function processPackages(Event $event) $configFile, Yaml::dump($configData, 6, 2) ); - $this->io->write('Creating config cache file:' . $configFile); + $this->io->write('Creating packages config cache file:'); + $this->io->write($configFile); } $servicesData = $extenderManager->getServicesData(); @@ -116,7 +120,8 @@ public function processPackages(Event $event) $servicesFile, Yaml::dump($servicesData['install'], 4, 2) ); - $this->io->write('Creating services cache file: ' . $servicesFile); + $this->io->write('Creating packages services cache file: '); + $this->io->write($servicesFile); } $servicesData = $extenderManager->getServicesData(); @@ -125,36 +130,29 @@ public function processPackages(Event $event) $servicesUninstallFile, Yaml::dump($servicesData['uninstall'], 4, 2) ); - $this->io->write('Creating services cache file: ' . $servicesUninstallFile); + $this->io->write('Creating packages services cache file: '); + $this->io->write($servicesUninstallFile); } - $this->removeCacheFiles(); + $this->removeCacheFiles($directory); } - protected function removeCacheFiles() + protected function removeCacheFiles($directory) { - if (is_dir(getcwd().'/console/cache/')) { - try { - $finder = new Finder(); - $finder->files() - ->in(getcwd() . '/console/cache/') - ->ignoreUnreadableDirs(); - - foreach ($finder as $file) { - unlink($file->getPathName()); - } - - $finder->directories() - ->in(getcwd() . '/console/cache/') - ->ignoreUnreadableDirs(); - - foreach ($finder as $directory) { - rmdir($directory); - } - - } catch (\InvalidArgumentException $argumentException) { - $this->io->write('Cache files can not be deleted'); + try { + $finder = new Finder(); + $finder->files() + ->in($directory) + ->name('*-console.services.yml') + ->ignoreUnreadableDirs(); + + foreach ($finder as $file) { + $this->io->write('Removing site services cache file:'); + $this->io->write($file->getPathName()); + unlink($file->getPathName()); } + } catch (\InvalidArgumentException $argumentException) { + $this->io->write('Cache file can not be deleted'); } } }