本文整理汇总了PHP中Nette\Utils\Finder类的典型用法代码示例。如果您正苦于以下问题:PHP Finder类的具体用法?PHP Finder怎么用?PHP Finder使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Finder类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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: 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
示例3: 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
示例4: 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
示例5: 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
示例6: 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
示例7: 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
示例8: 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
示例9: 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
示例10: 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
示例11: flush
public function flush()
{
/** @var $file \SplFileInfo */
foreach (Finder::findFiles('*')->in($this->getAbsolutePath()) as $file) {
@unlink($file->getRealPath());
}
}
开发者ID:peterzadori,项目名称:movi,代码行数:7,代码来源:FileStorage.php
示例12: 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
示例13: 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
示例14: 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
示例15: 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
示例16: 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
示例17: 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
示例18: 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
示例19: 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
示例20: 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
注:本文中的Nette\Utils\Finder类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论