Пример #1
0
 public function deleteMatched($matcher, array $options = [])
 {
     $allFiles = Toolbox\FileTools::searchFile($this->basePath);
     foreach ($allFiles as $file) {
         $key = urldecode(substr($file, strrpos($file, DIRECTORY_SEPARATOR) + 1));
         if (preg_match($matcher, $key)) {
             $this->getEntry($key, [])->delete();
         }
     }
 }
Пример #2
0
 public function deleteMatched($matcher, array $options = [])
 {
     $allFiles = Toolbox\FileTools::searchFile($this->basePath);
     foreach ($allFiles as $file) {
         $key = urldecode(substr($file, strrpos($file, DIRECTORY_SEPARATOR) + 1));
         if (preg_match($matcher, $key)) {
             $this->getEntry($key, [])->delete();
         }
     }
     foreach (Toolbox\FileTools::listFilesRecursive($this->basePath) as $finfo) {
         $key = $finfo->getBaseName();
         $entry = $this->getEntry($key, []);
         if ($entry->expired()) {
             $entry->delete();
         }
     }
 }
Пример #3
0
 /**
  * Deletes everything inside the compile folder.
  */
 public function emptyCompileDir()
 {
     $this->console("Deleting compiled assets");
     $dir = $this->compilePath() . $this->prefix();
     if (is_dir($dir)) {
         Rails\Toolbox\FileTools::emptyDir($dir);
     }
 }
Пример #4
0
 public function includeFactories(array $paths)
 {
     $includer = ClassTools::generateFileIncluder($this);
     foreach ($paths as $path) {
         foreach (FileTools::listFilesRecursive($path) as $file) {
             $includer($file->getRealPath());
         }
     }
 }
Пример #5
0
 protected function requireTree($tree)
 {
     $rootDir = $this->file->full_dir();
     $path = $rootDir . '/' . $tree;
     $realPath = realpath($path);
     if (!$realPath) {
         throw new Exception\RuntimeException(sprintf("Path to tree not found: %s", $path));
     }
     # Require files in root directory.
     $this->requireDir($tree);
     # Require files in sub directories.
     $allDirs = Toolbox\FileTools::listDirs($realPath);
     foreach ($allDirs as $dir) {
         $relativeDir = trim(substr($dir, strlen($rootDir)), '/');
         $this->requireDir($relativeDir);
     }
 }
Пример #6
0
 private function runInitializers()
 {
     $dirName = 'initializers';
     $path = $this->config()->paths->config->concat($dirName);
     if (is_dir($path)) {
         $files = [];
         $patt = $path . '/*.php';
         $files = array_merge($files, glob($patt) ?: []);
         foreach (Toolbox\FileTools::listDirs($path) as $dir) {
             $patt = $dir . '/*.php';
             $files = array_merge($files, glob($patt) ?: []);
         }
         foreach ($files as $file) {
             require $file;
         }
     }
 }