Esempio n. 1
0
 /**
  * due to Doctrine cache deleteAll() cannot really delete file/folder for FilesystemCache, it just left old cache file and create new cache folder.<br>
  * this method is for really delete all cache and all file (in specified sub folder if it was set).
  * 
  * @return boolean
  */
 public function deleteAllFile()
 {
     $result = $this->deleteAll();
     if (isset($this->cache_config['driver']) && $this->cache_config['driver'] == 'Filesystem' && isset($this->cache_config['cache_path'])) {
         $adapter = new \League\Flysystem\Adapter\Local($this->cache_config['cache_path']);
         $Filesystem = new \League\Flysystem\Filesystem($adapter);
         $Filesystem->addPlugin(new \League\Flysystem\Plugin\ListPaths());
         if ($this->cache_config['cache_path'] . $this->subFolder == STORAGE_PATH . DS . 'cms' . DS . 'cache') {
             // sub folder may not set and cache path is match main cache folder.
             $files = $Filesystem->listPaths($this->subFolder);
             if (is_array($files)) {
                 foreach ($files as $file) {
                     if ($file != '.gitignore' && is_dir($this->cache_config['cache_path'] . $this->subFolder . '/' . $file)) {
                         $Filesystem->deleteDir($file);
                     } elseif ($file != '.gitignore' && is_file($this->cache_config['cache_path'] . $this->subFolder . '/' . $file)) {
                         $Filesystem->delete($file);
                     }
                 }
                 unset($file);
             }
             unset($files);
         } else {
             // sub folder is set.
             $files = $Filesystem->listPaths('');
             if (is_array($files)) {
                 foreach ($files as $file) {
                     if (is_dir($this->cache_config['cache_path'] . '/' . $file)) {
                         $Filesystem->deleteDir($file);
                     } elseif (is_file($this->cache_config['cache_path'] . '/' . $file)) {
                         $Filesystem->delete($file);
                     }
                 }
                 unset($file);
             }
             unset($files);
         }
     }
     return $result;
 }