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


PHP Finder::findFiles方法代码示例

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


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

示例1: beforeRender

 public function beforeRender()
 {
     $dir = $this->getAbsoluteDirectory();
     $this->template->rootDir = $this->getRoot();
     $this->template->rootDirProvider = $this->rootDir;
     $this->template->fileSystemCurrent = Nette\Utils\Finder::findFiles('*')->in($dir);
 }
开发者ID:zaxxx,项目名称:zaxcms,代码行数:7,代码来源:FileListControl.php

示例2: execute

 protected function execute(InputInterface $input, OutputInterface $output)
 {
     Debugger::timer();
     $output->writeln('Running tests...');
     $runner = new Runner();
     $path = realpath($input->getArgument('path'));
     if ($path) {
         if (is_dir($path)) {
             $runner->setTestsRoot($path . '/');
             foreach (Finder::findFiles('*.php')->exclude('tester.php')->from($path) as $path => $fileInfo) {
                 $basePath = Helpers::stripExtension($path);
                 $runner->addTest($basePath);
             }
         } else {
             $basePath = Helpers::stripExtension($path);
             $runner->addTest($basePath);
         }
     } else {
         if ($path = realpath($input->getArgument('path') . '.php')) {
             $basePath = Helpers::stripExtension($path);
             $runner->addTest($basePath);
         } else {
             $output->writeln("<error>The given path isn't valid</error>");
             return 1;
         }
     }
     $runner->setOutput($output);
     $runner->runTests();
     $output->writeln('Completed in ' . round(Debugger::timer(), 2) . ' seconds');
     if ($runner->failed()) {
         return 1;
     } else {
         return 0;
     }
 }
开发者ID:blocka,项目名称:php2js,代码行数:35,代码来源:TestCommand.php

示例3: build

 public function build()
 {
     foreach (\Nette\Utils\Finder::findFiles('*.latte')->from($this->settings->template) as $template) {
         $destination = $this->settings->netteRoot . str_replace($this->settings->template, '', mb_substr($template, 0, -6));
         if (mb_strpos($destination, '\\Module') !== FALSE) {
             $destination = str_replace('\\Module', $this->settings->module ? '\\' . $this->settings->module . 'Module' : '\\', $destination);
         }
         if (mb_strpos($destination, '\\NDBT') !== FALSE && $this->settings->target !== \Utils\Constants::TARGET_NETTE_DATABASE || mb_strpos($destination, '\\D2') !== FALSE && $this->settings->target !== \Utils\Constants::TARGET_DOCTRINE2) {
             continue;
         } else {
             $destination = str_replace(['\\NDBT', '\\D2'], '\\', $destination);
         }
         if (mb_strpos($destination, '\\Table') !== FALSE) {
             foreach ($this->settings->tables as $table) {
                 $this->parameters['table'] = $table;
                 $newDestination = str_replace('\\Table', "\\{$table->sanitizedName}", $destination);
                 if (mb_strpos(basename($destination), '.') !== FALSE) {
                     $this->saveTemplate($newDestination, $this->processTemplate($template, $this->parameters));
                 } else {
                     $this->processTemplate($newDestination, $this->parameters);
                 }
             }
         } else {
             if (mb_strpos(basename($destination), '.') !== FALSE) {
                 $this->saveTemplate($destination, $this->processTemplate($template, $this->parameters));
             } else {
                 $this->processTemplate($template, $this->parameters);
             }
         }
     }
     foreach (\Nette\Utils\Finder::findFiles('*.*')->exclude('*.latte')->from($this->settings->template) as $template) {
         $destination = $this->settings->netteRoot . str_replace($this->settings->template, '', $template);
         \Nette\Utils\FileSystem::copy($template, $destination);
     }
 }
开发者ID:r-bruha,项目名称:nette-generator,代码行数:35,代码来源:Builder.php

示例4: parseFiles

 /**
  * Parse all the exception files found in /log/*.html
  * Checks if they are in log_error table, if not it includes them there
  */
 public function parseFiles()
 {
     foreach (Nette\Utils\Finder::findFiles('*.html')->in($this->logDir) as $file) {
         $lstErrorTp = $this->lstErrorTp->getByName("exception");
         $filePath = $this->getExceptionFilePath($file->getFilename());
         if (is_file($filePath)) {
             $parse = file_get_contents($filePath, false, null, -1, 600);
             $titleStart = strpos($parse, "<title>");
             $titleLineEnds = strpos($parse, "-->", $titleStart);
             $message = str_replace(array("<title>", "</title><!-- "), array("", ": "), substr($parse, $titleStart, $titleLineEnds - $titleStart));
             if (empty($message) || strlen($message) < 3) {
                 $message = "Unparsable name!";
             }
             $row = $this->logError->getTable()->where(array("log_error.del_flag" => 0, "message" => $message, "error_tp.name" => "exception", "url" => $file->getFilename(), "log_error.ins_dt" => date('Y-m-d H:i:s', $file->getMTime())))->fetch();
             if (!$row) {
                 $inserted = $this->logError->getTable()->insert(array("message" => $message, "file_content" => file_get_contents($filePath), "url" => $file->getFilename(), "ins_dt" => date('Y-m-d H:i:s', $file->getMTime()), "error_tp_id" => $lstErrorTp->id, "del_flag" => 0, "ins_process_id" => "HQ\\ExceptionService::parseFiles()"));
                 if ($inserted) {
                     unlink($filePath);
                 }
             }
         } else {
             $this->logger->logError("404", "Could not reach exception file to parse: " . $file->getFileName());
         }
     }
 }
开发者ID:RiKap,项目名称:ErrorMonitoring,代码行数:29,代码来源:ExceptionService.php

示例5: flush

 public function flush()
 {
     /** @var $file \SplFileInfo */
     foreach (Finder::findFiles('*')->in($this->getAbsolutePath()) as $file) {
         @unlink($file->getRealPath());
     }
 }
开发者ID:peterzadori,项目名称:movi,代码行数:7,代码来源:FileStorage.php

示例6: beforeRender

 public function beforeRender()
 {
     $dir = $this->getAbsoluteDirectory();
     if ($this->usageInfo) {
         $rootSize = 0;
         $rootCountFiles = 0;
         foreach (Nette\Utils\Finder::findFiles('*')->from($this->getRoot()) as $file) {
             $rootSize += $file->getSize();
             $rootCountFiles++;
         }
         $subSizes = [];
         $subCountFiles = [];
         foreach ($this->getSubdirectories() as $path => $subdir) {
             $subSizes[$path] = 0;
             $subCountFiles[$path] = 0;
             foreach (Nette\Utils\Finder::findFiles('*')->from($subdir) as $file) {
                 $subSizes[$path] += $file->getSize();
                 $subCountFiles[$path]++;
             }
         }
         $this->template->subSizes = $subSizes;
         $this->template->rootSize = $rootSize;
         $this->template->rootCountFiles = $rootCountFiles;
         $this->template->subCountFiles = $subCountFiles;
     }
     $this->template->rootDir = $this->getRoot();
     $this->template->currentDir = $dir;
     $this->template->fileSystemDirs = $this->getSubdirectories();
     $this->template->usageInfo = $this->usageInfo;
 }
开发者ID:zaxxx,项目名称:zaxcms,代码行数:30,代码来源:DirectoryListControl.php

示例7: getAssets

 /**
  * @param array $resources
  * @param bool $minify
  * @param string $baseDir
  * @throws AssetsException
  * @return array
  */
 public function getAssets(array $resources, $minify, $baseDir)
 {
     $config = [];
     $return = [];
     foreach ($resources as $resource) {
         $contents = file_get_contents($resource);
         $decompiled = Strings::endsWith($resource, '.json') ? json_decode($contents, TRUE) : Neon::decode($contents);
         $config = \Nette\DI\Config\Helpers::merge($config, $decompiled);
     }
     foreach ($config as $moduleArray) {
         foreach ($moduleArray as $type => $typeArray) {
             if (!isset(self::$supportTypes[$type])) {
                 throw new AssetsException("Found section '{$type}', but expected one of " . implode(', ', array_keys(self::$supportTypes)));
             }
             foreach ($typeArray as $minified => $assets) {
                 if ($minify) {
                     $return[$type][$minified] = TRUE;
                     continue;
                 }
                 foreach ((array) $assets as $row) {
                     if (strpos($row, '*') !== FALSE) {
                         /** @var \SplFileInfo $file */
                         foreach (Finder::findFiles(basename($row))->in($baseDir . '/' . dirname($row)) as $file) {
                             $return[$type][$minified][] = dirname($row) . '/' . $file->getBasename();
                         }
                     } else {
                         $return[$type][$minified][] = $row;
                     }
                 }
             }
         }
     }
     return $return;
 }
开发者ID:webchemistry,项目名称:assets,代码行数:41,代码来源:AssetsExtension.php

示例8: loadConfigFiles

 /**
  * @param Configurator $configurator
  */
 protected function loadConfigFiles(Configurator $configurator)
 {
     if ($this->autoloadConfig === TRUE || is_array($this->autoloadConfig)) {
         $scanDirs = $this->autoloadConfig === TRUE ? [$this->appDir] : $this->autoloadConfig;
         $cache = $this->createCache();
         $files = $cache->load(self::CACHE_NAMESPACE);
         if ($files === NULL) {
             $files = [0 => []];
             foreach (Finder::findFiles('*.neon')->from($scanDirs) as $path => $file) {
                 $content = Neon::decode(file_get_contents($path));
                 if (!is_array($content) || !array_key_exists('autoload', $content)) {
                     continue;
                 }
                 $autoload = Arrays::get($content, ['autoload', 0], FALSE);
                 if ($autoload === FALSE) {
                     continue;
                 }
                 $autoload = is_int($autoload) ? $autoload : 0;
                 if (!isset($files[$autoload])) {
                     $files[$autoload] = [];
                 }
                 $files[$autoload][] = $path;
             }
             $cache->save(self::CACHE_NAMESPACE, $files);
         }
         foreach ($files as $priorityFiles) {
             foreach ($priorityFiles as $config) {
                 $configurator->addConfig($config);
             }
         }
     }
     foreach ($this->configs as $config) {
         $configurator->addConfig($config);
     }
 }
开发者ID:zaxcms,项目名称:framework,代码行数:38,代码来源:ZaxBootstrap.php

示例9: run

 public function run()
 {
     foreach (Finder::findFiles('*Test.php')->from(__DIR__) as $fileInfo) {
         /** @var \SplFileInfo $fileInfo*/
         $baseName = $fileInfo->getBasename('.php');
         if ($baseName === 'PhpRQTest') {
             continue;
         }
         $className = 'PhpRQ\\' . $baseName;
         $reflection = new \ReflectionClass($className);
         if (!$reflection->isInstantiable()) {
             continue;
         }
         foreach ($reflection->getMethods() as $method) {
             if (!$method->isPublic() || strpos($methodName = $method->getName(), 'test') === false) {
                 continue;
             }
             $phpdoc = $method->getDocComment();
             if ($phpdoc !== false && ($providerPos = strpos($phpdoc, '@dataProvider')) !== false) {
                 $providerMethodPos = $providerPos + 14;
                 $providerMethodLen = strpos($phpdoc, "\n", $providerMethodPos) - $providerMethodPos;
                 $providerMethod = substr($phpdoc, $providerMethodPos, $providerMethodLen);
                 $testCase = new $className($this->provider->getRedisClient());
                 foreach ($testCase->{$providerMethod}() as $args) {
                     $testCase = new $className($this->provider->getRedisClient());
                     call_user_func_array([$testCase, $methodName], (array) $args);
                 }
             } else {
                 $testCase = new $className($this->provider->getRedisClient());
                 $testCase->{$methodName}();
             }
         }
     }
 }
开发者ID:heureka,项目名称:php-rq,代码行数:34,代码来源:TestRunner.php

示例10: clearTemp

 private function clearTemp()
 {
     /* @var $file SplFileInfo  */
     foreach (Finder::findFiles('*')->from($this->temp) as $file) {
         @unlink($file->getPathname());
     }
 }
开发者ID:Kaliver,项目名称:gettext-latte,代码行数:7,代码来源:LatteCompiler.php

示例11: getPresenters

 /**
  * @return array
  */
 private function getPresenters()
 {
     @SafeStream::register();
     //intentionally @ (prevents multiple registration warning)
     $tree = array();
     foreach (Finder::findFiles('*Presenter.php')->from(APP_DIR) as $path => $file) {
         $data = $this->processPresenter($file);
         if ($data === FALSE) {
             continue;
         }
         list($module, $presenter, $actions) = $data;
         $tree[$module][$presenter] = $actions;
     }
     foreach (Finder::findFiles('*.latte', '*.phtml')->from(APP_DIR) as $path => $file) {
         $data = $this->processTemplate($file);
         if ($data === FALSE) {
             continue;
         }
         list($module, $presenter, $action) = $data;
         if (!isset($tree[$module][$presenter])) {
             $tree[$module][$presenter] = array();
         }
         if (array_search($action, $tree[$module][$presenter]) === FALSE) {
             $tree[$module][$presenter][] = $action;
         }
     }
     $tree = $this->removeSystemPresenters($tree);
     return $tree;
 }
开发者ID:rostenkowski,项目名称:NavigationPanel,代码行数:32,代码来源:NavigationPanel.php

示例12: render

 public function render()
 {
     $editor = new OpenInEditor();
     $structure = (object) array('structure' => array());
     $isAll = true;
     foreach (Finder::findFiles('*Test.php')->from($this->dir) as $file) {
         $relative = substr($file, strlen($this->dir) + 1);
         $cursor =& $structure;
         foreach (explode(DIRECTORY_SEPARATOR, $relative) as $d) {
             $r = isset($cursor->relative) ? $cursor->relative . DIRECTORY_SEPARATOR : NULL;
             $cursor =& $cursor->structure[$d];
             $path = $this->dir . DIRECTORY_SEPARATOR . $r . $d;
             $open = $path === $this->open;
             if ($open) {
                 $isAll = false;
             }
             $cursor = (object) array('relative' => $r . $d, 'name' => $d, 'open' => $open, 'structure' => isset($cursor->structure) ? $cursor->structure : array(), 'editor' => $editor->link($path, 1), 'mode' => is_file($path) ? 'file' : 'folder');
             if (!$cursor->structure and $cursor->mode === 'file') {
                 foreach ($this->loadMethod($path) as $l => $m) {
                     $cursor->structure[$m] = (object) array('relative' => $cursor->relative . '::' . $m, 'name' => $m, 'open' => $cursor->open and $this->method === $m, 'structure' => array(), 'editor' => $editor->link($path, $l), 'mode' => 'method');
                 }
             }
         }
         $cursor->name = $file->getBasename();
     }
     $this->template->isAll = ($isAll and $this->open !== false);
     $this->template->basePath = TemplateFactory::getBasePath();
     $this->template->structure = $structure->structure;
     $this->template->setFile(__DIR__ . '/StructureRenderer.latte');
     $this->template->render();
 }
开发者ID:rostenkowski,项目名称:HttpPHPUnit,代码行数:31,代码来源:StructureRenderer.php

示例13: addFindConfig

 /**
  * Search configuration files.
  * @param mixed
  * @param mixed
  */
 public function addFindConfig($dirs, $exclude = NULL)
 {
     $cache = new Caching\Cache(new Caching\Storages\FileStorage($this->getCacheDirectory()), self::Caching);
     // Search will be started only when the cache does not exist.
     if (!$cache->load(self::Caching)) {
         // Search configuration files.
         foreach (Utils\Finder::findFiles('*.neon')->from($dirs)->exclude($exclude) as $row) {
             $data[] = $row->getPathname();
         }
         foreach ($data as $row) {
             $name[] = basename($row);
         }
         // Sort found files by number and put into the cache.
         array_multisort($name, SORT_NUMERIC, $data);
         if (isset($data)) {
             $cache->save(self::Caching, $data);
         }
     }
     // Loads the data from the cache.
     if ($cache->load(self::Caching)) {
         foreach ($cache->load(self::Caching) as $files) {
             $this->addConfig($files);
         }
     }
 }
开发者ID:drago-fw,项目名称:drago,代码行数:30,代码来源:Configurator.php

示例14: addWebLoader

 private function addWebLoader(\Nette\DI\ContainerBuilder $builder, $name, $config)
 {
     $filesServiceName = $this->prefix($name . 'Files');
     $files = $builder->addDefinition($filesServiceName)->setClass('WebLoader\\FileCollection')->setArguments(array($config['sourceDir']));
     foreach ($config['files'] as $file) {
         // finder support
         if (is_array($file) && isset($file['files']) && (isset($file['in']) || isset($file['from']))) {
             $finder = \Nette\Utils\Finder::findFiles($file['files']);
             unset($file['files']);
             foreach ($file as $method => $params) {
                 call_user_func_array(array($finder, $method), array($params));
             }
             foreach ($finder as $foundFile) {
                 $files->addSetup('addFile', array((string) $foundFile));
             }
         } else {
             $files->addSetup('addFile', array($file));
         }
     }
     $files->addSetup('addRemoteFiles', array($config['remoteFiles']));
     $compiler = $builder->addDefinition($this->prefix($name . 'Compiler'))->setClass('WebLoader\\Compiler')->setArguments(array('@' . $filesServiceName, $config['namingConvention'], $config['tempDir']));
     $compiler->addSetup('setJoinFiles', array($config['joinFiles']));
     foreach ($config['filters'] as $filter) {
         $compiler->addSetup('addFilter', array($filter));
     }
     foreach ($config['fileFilters'] as $filter) {
         $compiler->addSetup('addFileFilter', array($filter));
     }
     // todo css media
 }
开发者ID:norbe,项目名称:WebLoader,代码行数:30,代码来源:Extension.php

示例15: _after

 protected function _after()
 {
     foreach (\Nette\Utils\Finder::findFiles('*')->from(__DIR__ . '/../_data/tmp') as $file) {
         @unlink((string) $file);
     }
     @copy(__DIR__ . '/../_data/image.gif', __DIR__ . '/../_data/assets/original/image.gif');
     // move in FileUpload
 }
开发者ID:webchemistry,项目名称:images,代码行数:8,代码来源:FileStorageTest.php


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