/**
  * provides default parameters for the FileFinder::find() method
  *
  * @see FileFinder::find()
  * @return An array with the new locales found in the disk
  */
 function find()
 {
     // first find the new ones
     parent::find(Locales::getAvailableLocales(), "locale_*.php");
     // and then return them, if any
     return $this->getNew();
 }
 protected function findFiles($root, $checksums, $type, $path, $mode)
 {
     $finder = new FileFinder($root);
     $finder->setGenerateChecksums($checksums)->excludePath("./exclude")->excludePath("subdir.txt")->withType($type)->withPath($path)->withSuffix('txt')->setForceMode($mode);
     $files = $finder->find();
     return $files;
 }
 public static function getPatchList()
 {
     $root = dirname(phutil_get_library_root('phabricator'));
     // Find the patch files
     $patches_dir = $root . '/resources/sql/patches/';
     $finder = new FileFinder($patches_dir);
     $results = $finder->find();
     $versions = array();
     $patches = array();
     foreach ($results as $path) {
         $matches = array();
         if (!preg_match('/(\\d+)\\..*\\.(sql|php)$/', $path, $matches)) {
             continue;
         }
         $version = (int) $matches[1];
         $patches[] = array('version' => $version, 'path' => $patches_dir . $path);
         if (empty($versions[$version])) {
             $versions[$version] = true;
         } else {
             throw new Exception("Two patches have version {$version}!");
         }
     }
     // Files are in some 'random' order returned by the operating system
     // We need to apply them in proper order
     $patches = isort($patches, 'version');
     return $patches;
 }
 /**
  * @see FileFinder::find()
  * @return An array with the ids of the new template sets
  */
 function find($currentTemplates = null)
 {
     // if no parameter, then use the list of default global templates
     if ($currentTemplates == null) {
         $currentTemplates = TemplateSets::getGlobalTemplates();
     }
     // call the parent method after the preparations
     parent::find($currentTemplates);
     // and return any new templates
     return $this->getNew();
 }
 public function buildFileContentHashes()
 {
     $files = array();
     $root = $this->getConfiguration()->getProjectRoot();
     $finder = new FileFinder($root . '/src');
     $finder->excludePath('*/.*')->withSuffix('js')->withType('f')->setGenerateChecksums(true);
     foreach ($finder->find() as $path => $hash) {
         $path = Filesystem::readablePath($path, $root);
         $files[$path] = $hash;
     }
     return $files;
 }
Exemplo n.º 6
0
 public function testNotFound()
 {
     $ff = new FileFinder(__DIR__ . '/*.php');
     $result = $ff->find('not-found.txt');
     $this->assertNull($result);
 }
Exemplo n.º 7
0
 /**
  * @return array of WikiPages
  */
 public function getPages()
 {
     $self = $this;
     return Lazy::init($this->_pages, function () use($self) {
         $pages = array();
         foreach (FileFinder::find($self->path, ['fileExt' => WikiRepository::getAvailableFileTypes()]) as $file) {
             $pages[] = $self->getPageByName($file, false);
         }
         return $pages;
     });
 }