Nette\Utils\Finder::find PHP Метод

find() публичный статический Метод

Begins search for files matching mask and all directories.
public static find ( $masks ) : self
Результат self
    public static function find(...$masks)
    {
        $masks = is_array($masks[0]) ? $masks[0] : $masks;
        return (new static())->select($masks, 'isDir')->select($masks, 'isFile');
    }

Usage Example

Пример #1
0
 /**
  * Generate dir structure tree
  *
  * @param string  $dir       Path to root dir
  * @param boolean $showFiles Show files
  *
  * @return \Nette\Utils\Html
  */
 private function generateTree($dir, $showFiles = true)
 {
     if (!is_dir($dir)) {
         throw new \Exception("Directory '{$dir}' does not exist!");
     }
     if ($showFiles) {
         $files = Finder::find("*")->in($dir);
     } else {
         $files = Finder::findDirectories("*")->in($dir);
     }
     $list = Html::el("ul");
     foreach ($files as $file) {
         // Create file link
         $link = Html::el("a")->href($file->getRealPath())->title($file->getRealPath());
         if ($file->isDir()) {
             $link[0] = Html::el("i")->class("icon-folder-open");
         } else {
             $link[0] = Html::el("i")->class("icon-file");
         }
         $link[1] = Html::el("span", Strings::truncate($file->getFileName(), 30));
         // Create item in list
         $item = Html::el("li");
         $item[0] = $link;
         if ($file->isDir()) {
             $item[1] = $this->generateTree($file->getPathName(), $showFiles);
         }
         $list->add($item);
     }
     return $list;
 }
All Usage Examples Of Nette\Utils\Finder::find