当前位置: 首页>>代码示例>>PHP>>正文


PHP Finder::find方法代码示例

本文整理汇总了PHP中Nette\Utils\Finder::find方法的典型用法代码示例。如果您正苦于以下问题:PHP Finder::find方法的具体用法?PHP Finder::find怎么用?PHP Finder::find使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Nette\Utils\Finder的用法示例。


在下文中一共展示了Finder::find方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: generateTree

 /**
  * 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;
 }
开发者ID:ixtrum,项目名称:forms,代码行数:38,代码来源:PathSelect.php

示例2: wipeCache

 public function wipeCache()
 {
     $paths = [realpath($this->tempDir . '/cache'), realpath($this->tempDir . '/proxy')];
     foreach (Nette\Utils\Finder::find('*')->in($paths) as $k => $file) {
         Nette\Utils\FileSystem::delete($k);
     }
 }
开发者ID:zaxxx,项目名称:zaxcms,代码行数:7,代码来源:CMSInstaller.php

示例3: addAutoloadConfig

 /**
  * @param string $path
  * @param string $find
  * @param int $depth
  */
 public function addAutoloadConfig($path, $find = 'config.neon', $depth = -1)
 {
     // Development
     if (!$this->cacheConfig && $this->isDevelopment()) {
         foreach (Finder::find($find)->from($path)->limitDepth($depth) as $file) {
             $this->addConfig((string) $file);
         }
         return;
     }
     // Production
     $directory = $this->parameters['tempDir'] . '/cache/configs';
     $cachePath = $directory . '/' . Strings::webalize(str_replace(dirname($this->parameters['appDir']), '', $path)) . '.neon';
     if (file_exists($cachePath)) {
         $this->addConfig($cachePath);
         return;
     }
     $encoder = new Encoder();
     $decoder = new Decoder();
     @mkdir($directory);
     $content = [];
     foreach (Finder::find($find)->from($path)->limitDepth($depth) as $file) {
         $content = Helpers::merge($content, $decoder->decode(file_get_contents($file)));
     }
     file_put_contents($cachePath, $encoder->encode($content));
     $this->addConfig($cachePath);
 }
开发者ID:ThunboltCMS,项目名称:configuration,代码行数:31,代码来源:Configuration.php

示例4: copy

 private function copy($dir, $targetDir)
 {
     $files = [];
     /** @var $file \SplFileInfo */
     foreach (Finder::find('*')->from($dir) as $file) {
         if ($file->isFile()) {
             $filename = $this->getRelativePath($file->getPathname(), $dir);
             $files[$filename] = $file;
         }
     }
     foreach ($files as $filename => $file) {
         $target = $targetDir . '/' . $filename;
         $dir = (new \SplFileInfo($target))->getPath();
         if (!file_exists($dir)) {
             umask(00);
             mkdir($dir, 0777, true);
         }
         if (Strings::lower($file->getExtension()) == 'zip' && extension_loaded('zlib')) {
             $archive = new \ZipArchive();
             $res = $archive->open($file->getRealPath());
             if ($res === true) {
                 $archive->extractTo($targetDir);
                 $archive->close();
             }
             continue;
         }
         @copy($file->getPathname(), $target);
     }
 }
开发者ID:peterzadori,项目名称:movi,代码行数:29,代码来源:ResourceInstaller.php

示例5: run

 public function run()
 {
     if (!$this->srcPath) {
         throw new \UnexpectedValueException("Please specify srcPath first.");
     }
     if (!$this->targetPath) {
         throw new \UnexpectedValueException("Please specify targetPath first.");
     }
     if (!is_dir($this->targetPath)) {
         mkdir($this->targetPath, 0777);
     }
     $lastLessEditTime = 0;
     foreach (\Nette\Utils\Finder::find("*.less")->from($this->getSrcPath()) as $file) {
         $lastLessEditTime = max($lastLessEditTime, $file->getMTime());
     }
     $lastCompileTime = 0;
     foreach (\Nette\Utils\Finder::find("*.css")->from($this->getTargetPath()) as $file) {
         $lastCompileTime = max($lastCompileTime, $file->getMTime());
     }
     $compiler = new \lessc();
     foreach ($this->getfilesMapping() as $src => $target) {
         if (!is_file($this->targetPath . "/" . $target) || $lastLessEditTime > $lastCompileTime) {
             $compiler->compileFile($this->srcPath . "/" . $src, $this->targetPath . "/" . $target);
         }
     }
 }
开发者ID:mlezitom,项目名称:less-compiler,代码行数:26,代码来源:LessCompiler.php

示例6: clean

 public function clean($time)
 {
     foreach (\Nette\Utils\Finder::find('*')->exclude('.*')->from($this->dir)->childFirst() as $file) {
         if ($file->isFile() && $file->getATime() < $time) {
             unlink((string) $file);
         }
     }
 }
开发者ID:arachne,项目名称:resources,代码行数:8,代码来源:PublicCache.php

示例7: loadFromDirectory

 /**
  * {@inheritdoc}
  */
 private function loadFromDirectory($path)
 {
     $files = [];
     foreach (Finder::find(['*.neon', '*.yaml', '*.yml'])->from($path) as $file) {
         $files[] = $file;
     }
     return $this->load($files);
 }
开发者ID:enumag,项目名称:DoctrineFixtures,代码行数:11,代码来源:AliceLoader.php

示例8: loadConfigFiles

 /**
  * @param string $path
  *
  * @return array
  */
 private function loadConfigFiles($path)
 {
     $files = [];
     /** @var \SplFileInfo $file */
     foreach (Nette\Utils\Finder::find('config/hotplug.neon')->from($path) as $file) {
         $files[] = $file->getPathname();
     }
     return $files;
 }
开发者ID:sw2eu,项目名称:hotplug,代码行数:14,代码来源:Configurator.php

示例9: getModifyTime

 /**
  * @param array $sourceFiles
  * @return int
  */
 protected function getModifyTime($sourceFiles)
 {
     $time = 0;
     foreach ($sourceFiles as $sourceFile) {
         /** @var \SplFileInfo $file */
         foreach (Finder::find("*.scss")->from(dirname($sourceFile)) as $file) {
             $time = max($time, $file->getMTime());
         }
     }
     return $time;
 }
开发者ID:sw2eu,项目名称:load-sass,代码行数:15,代码来源:SassCompiler.php

示例10: cleanSessions

 public function cleanSessions()
 {
     foreach (Finder::find('*')->in($this->sessionsDir) as $file) {
         $path = $file->getPathname();
         if (is_dir($path)) {
             File::rmdir($path, TRUE);
         } else {
             unlink($path);
         }
     }
 }
开发者ID:svobodni,项目名称:web,代码行数:11,代码来源:CacheManager.php

示例11: clearTemp

function clearTemp($directory = TEMP_DIR)
{
    $files = \Nette\Utils\Finder::find('*')->exclude('.*')->in($directory);
    foreach ($files as $path => $file) {
        if ($file->isDir()) {
            clearTemp($path);
            @rmdir($path);
        } else {
            @unlink($path);
        }
    }
    @rmdir($directory);
}
开发者ID:Lawondyss,项目名称:CDNLoader,代码行数:13,代码来源:bootstrap.php

示例12: purgeDir

 /**
  * @param string $path
  */
 public static function purgeDir($path)
 {
     if (!is_dir($path)) {
         mkdir($path, 0755, TRUE);
     }
     foreach (Nette\Utils\Finder::find('*')->from($path)->childFirst() as $item) {
         /** @var \SplFileInfo $item */
         if ($item->isDir()) {
             rmdir($item);
         } elseif ($item->isFile()) {
             unlink($item);
         }
     }
 }
开发者ID:brighten01,项目名称:opencloud-zendframework,代码行数:17,代码来源:FileSystem.php

示例13: purgeDir

 /**
  * @param string $path
  */
 public function purgeDir($path)
 {
     if (!is_dir($path)) {
         mkdir($path, 0755, true);
     }
     foreach (Finder::find('*')->from($path)->childFirst() as $item) {
         /** @var \SplFileInfo $item */
         if ($item->isDir()) {
             rmdir($item);
         } else {
             unlink($item);
         }
     }
 }
开发者ID:apigen,项目名称:apigen,代码行数:17,代码来源:FileSystem.php

示例14: run

 public function run(InputInterface $input, OutputInterface $output)
 {
     $latte = $this->getHelper('container')->getByType(ITemplateFactory::class)->createTemplate()->getLatte();
     $counter = [0, 0];
     foreach (Finder::find('*.latte')->from($this->source) as $name => $file) {
         try {
             $latte->warmupCache($name);
             $counter[0]++;
         } catch (\Exception $e) {
             $counter[1]++;
         }
     }
     $output->writeln(sprintf('%s templates successfully compiled, %s failed.', $counter[0], $counter[1]));
 }
开发者ID:lookyman,项目名称:commands,代码行数:14,代码来源:CompileTemplatesCommand.php

示例15: actionClean

 /**
  * Akce pro smazání obsahu adresáře, do kterého se ukládá aplikační cache
  * @throws \Nette\Application\AbortException
  */
 public function actionClean()
 {
     $deletedArr = [];
     $errorArr = [];
     foreach (Finder::find('*')->in(CACHE_DIRECTORY) as $file => $info) {
         try {
             FileSystem::delete($file);
             $deletedArr[] = $file;
         } catch (\Exception $e) {
             $errorArr[] = $file;
         }
     }
     $response = ['state' => empty($errorArr) ? 'OK' : 'error', 'deleted' => $deletedArr, 'errors' => $errorArr];
     $this->sendJson($response);
 }
开发者ID:kizi,项目名称:easyminer-easyminercenter,代码行数:19,代码来源:CachePresenter.php


注:本文中的Nette\Utils\Finder::find方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。