Пример #1
0
 /**
  * Deletes specified directories by code
  *
  * @param array $directoryCodeList
  * @return void
  */
 public function cleanupFilesystem($directoryCodeList)
 {
     $excludePatterns = ['#.htaccess#', '#deployed_version.txt#'];
     foreach ($directoryCodeList as $code) {
         if ($code == DirectoryList::STATIC_VIEW) {
             $directoryPath = $this->directoryList->getPath(DirectoryList::STATIC_VIEW);
             if ($this->driverFile->isExists($directoryPath)) {
                 $files = $this->driverFile->readDirectory($directoryPath);
                 foreach ($files as $file) {
                     foreach ($excludePatterns as $pattern) {
                         if (preg_match($pattern, $file)) {
                             continue 2;
                         }
                     }
                     if ($this->driverFile->isFile($file)) {
                         $this->driverFile->deleteFile($file);
                     } else {
                         $this->driverFile->deleteDirectory($file);
                     }
                 }
             }
         } else {
             $this->filesystem->getDirectoryWrite($code)->delete();
         }
     }
 }