本文整理汇总了PHP中Nette\Utils\Finder::findDirectories方法的典型用法代码示例。如果您正苦于以下问题:PHP Finder::findDirectories方法的具体用法?PHP Finder::findDirectories怎么用?PHP Finder::findDirectories使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Nette\Utils\Finder
的用法示例。
在下文中一共展示了Finder::findDirectories方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: beforeRender
public function beforeRender()
{
$albumsPaths = null;
$path = 'gallery/';
$a = 0;
$albumsNames = null;
if (strtoupper(substr(PHP_OS, 0, 3)) === 'WIN') {
DIRECTORY_SEPARATOR == '/';
} else {
DIRECTORY_SEPARATOR == '\\';
}
foreach (Finder::findDirectories('*')->exclude('[0-9][0-9][0-9]', '_big')->in($path) as $key => $file) {
$albumsNames[] = str_replace("gallery" . DIRECTORY_SEPARATOR, "", $key);
$albumsPaths[] = $key;
$i = 0;
$nImg = 0;
if (($files = @scandir($key)) && count($files) <= 2) {
$albumImgs[$a] = null;
$this->template->thumbs = null;
} else {
foreach (Finder::findFiles('*.jpg', '*.png', '*.jpeg', '*.JPG', '*.PNG', '*.JPEG')->in($key) as $key2 => $file) {
$albumImgs[$a] = $file->getFilename();
$i++;
}
$this->template->thumbs = $albumImgs;
}
$a++;
}
$this->template->albumsNames = $albumsNames;
}
示例2: 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;
}
示例3: getAvailableThemes
public function getAvailableThemes()
{
$directories = array_keys(iterator_to_array(Finder::findDirectories('*')->in($this->getThemesDir())));
array_walk($directories, function (&$item) {
$item = basename($item);
});
return $directories;
}
示例4: getUnimportedTasks
private function getUnimportedTasks($folder)
{
$importedExperiments = \Nette\Utils\Finder::findDirectories('*')->in($folder)->imported(TRUE)->toArray();
if (count($importedExperiments) == 0) {
return array();
}
return \Nette\Utils\Finder::findDirectories('*')->in($importedExperiments)->imported(FALSE)->aborted(FALSE);
}
示例5: getDeclaredNamespaces
/**
* Returns all declared namespaces
*
* @return array
*/
public function getDeclaredNamespaces()
{
$namespaces = array();
/** @var $file \SplFileInfo */
foreach (Finder::findDirectories("*")->in($this->assetsDir)->exclude($this->generatedDirs) as $file) {
$namespaces[] = $file->getFilename();
}
return $namespaces;
}
示例6: findPackages
public function findPackages()
{
$packages = [];
foreach (Finder::findDirectories('*')->in($this->packagesDir) as $package) {
$package = $this->register($package);
$packages[$package['name']] = $package;
}
return $packages;
}
示例7: getLayoutsByModule
/**
* @param $module
* @return array
*/
public function getLayoutsByModule($module)
{
$data = array();
$path = $this->modules[$module]['path'] . '/Resources/layouts';
if (file_exists($path)) {
foreach (Finder::findDirectories("*")->in($path) as $file) {
if (file_exists($file->getPathname() . '/@layout.latte')) {
$data[$file->getBasename()] = "@{$module}Module/{$file->getBasename()}/@layout.latte";
}
}
}
return $data;
}
示例8: getArticle
/**
* @param string $keyIdentifier
* @return Article
* @throws ArticleKeyIdentifierNotValidException
* @throws ArticleNotFoundException
*/
public function getArticle($keyIdentifier) : Article
{
$articleFullPath = $this->getArticleFullPath();
$this->validateKeyIdentifier($keyIdentifier);
$mask = sprintf('*/*/%s', $keyIdentifier);
$result = Finder::findDirectories($mask)->from($articleFullPath);
$iterator = $result->getIterator();
$iterator->rewind();
if (($articleDirectory = $iterator->current()) === null) {
throw new ArticleNotFoundException(sprintf("Article identified by: '%s' NOT found.", $keyIdentifier));
}
$relativePath = $this->parseRelativePath($articleDirectory);
return $this->articleBuilder->getArticle($articleDirectory, $relativePath);
}
示例9: cleanAll
/**
* @param string $dir
*/
public static function cleanAll($dir)
{
foreach (\Nette\Utils\Finder::findFiles('*')->from($dir) as $file) {
unlink($file);
}
$array = iterator_to_array(\Nette\Utils\Finder::findDirectories('*')->from($dir));
usort($array, function ($a, $b) {
$aC = substr_count($a, '/') + substr_count($a, '\\');
$bC = substr_count($b, '/') + substr_count($b, '\\');
return $aC === $bC ? 0 : ($aC < $bC ? 1 : -1);
});
foreach ($array as $file) {
rmdir($file);
}
}
示例10: create
/**
* @return Form
*/
public function create()
{
$form = $this->factory->create();
$pages = $this->pagesRepository->getAll()->fetchPairs('id', 'name');
$themes = [];
foreach (Finder::findDirectories('*')->in(__DIR__ . '/../../../themes') as $dir) {
/** @var \SplFileInfo $dir */
$filename = $dir->getFilename();
$themes[$filename] = $filename;
}
$form->addText('siteName', "messages.settings.siteName")->setAttribute('placeholder', "messages.settings.siteName")->setAttribute('class', 'form-control input-sm')->setRequired("messages.settings.plsSiteName");
$form->addText('adminMail', "messages.settings.adminMail")->setAttribute('placeholder', "messages.settings.adminMail")->setAttribute('class', 'form-control input-sm')->setRequired("messages.settings.plsAdminMail");
$form->addText('companyMail', "messages.settings.companyMail")->setAttribute('placeholder', "messages.settings.companyMail")->setAttribute('class', 'form-control input-sm')->setRequired("messages.settings.plsCompanyMail");
$form->addText('companyPhone', "messages.settings.companyPhone")->setAttribute('placeholder', "messages.settings.companyPhone")->setAttribute('class', 'form-control input-sm')->setRequired("messages.settings.plsCompanyPhone");
$form->addText('companyAddress', "messages.settings.companyAddress")->setAttribute('placeholder', "messages.settings.companyAddress")->setAttribute('class', 'form-control input-sm')->setRequired("messages.settings.plsCompanyAddress");
$form->addText('noreplyMail', "messages.settings.noreplyMail")->setAttribute('placeholder', "messages.settings.noreplyMail")->setAttribute('class', 'form-control input-sm');
$form->addText('motto1', "messages.settings.motto1")->setAttribute('placeholder', "messages.settings.motto1")->setAttribute('class', 'form-control input-sm');
$form->addText('motto2', "messages.settings.motto2")->setAttribute('placeholder', "messages.settings.motto2")->setAttribute('class', 'form-control input-sm');
$form->addSelect('theme', "messages.settings.template", $themes)->setAttribute('class', 'form-control input-sm');
$form->addText('smtpHost', "messages.settings.smtpServer")->setAttribute('placeholder', "messages.settings.smtpServer")->setAttribute('class', 'form-control input-sm');
$form->addText('smtpUsername', "messages.settings.smtpUsername")->setAttribute('placeholder', "messages.settings.smtpUsername")->setAttribute('class', 'form-control input-sm');
$form->addText('smtpPassword', "messages.settings.smtpPassword")->setAttribute('placeholder', "messages.settings.smtpPassword")->setAttribute('class', 'form-control input-sm');
$form->addText('smtpSecure', "messages.settings.smtpSecure")->setAttribute('placeholder', "messages.settings.smtpSecure")->setAttribute('class', 'form-control input-sm');
$form->addCheckbox('useMail', "messages.settings.useMail")->setAttribute('placeholder', "messages.settings.useMail")->setAttribute('class', 'bootstrap');
$form->addTextArea('ownScript', "messages.settings.footerScript")->setAttribute('placeholder', "messages.settings.footerScript")->setAttribute('class', 'form-control input-sm')->setAttribute('rows', '20');
$form->addSelect('thanksPage', "messages.settings.thanksPage", $pages)->setAttribute('class', 'form-control input-sm select2');
$form->addCheckbox('showAsBlog', "messages.settings.showAsBlog")->setAttribute('class', 'bootstrap');
$form->addText('pagesPerPage', "messages.settings.pagesPerPage")->setAttribute('placeholder', "messages.settings.pagesPerPage")->setAttribute('class', 'form-control input-sm');
$form->addText('rowInRss', "messages.settings.rowInRss")->setAttribute('placeholder', "messages.settings.rowInRss")->setAttribute('class', 'form-control input-sm');
$form->addText('logo', "messages.settings.logo")->setAttribute('placeholder', "messages.settings.logo")->setAttribute('onclick', 'openKCFinder(this)')->setAttribute('class', 'form-control input-sm');
$form->addText('sliderInterval', "messages.settings.interval")->setAttribute('placeholder', "messages.settings.interval")->setAttribute('class', 'form-control input-sm');
$form->addSubmit('process', "messages.settings.btnSubmit")->setAttribute('class', 'btn btn-primary');
$form->setRenderer(new BootstrapRenderer());
$form->onSuccess[] = function (Form $form) {
$this->formSucceeded($form);
};
return $form;
}
示例11: foreach
<?php
/**
* Created by PhpStorm.
* User: Azathoth
* Date: 10. 1. 2016
* Time: 15:29
*/
require_once 'vendor/autoload.php';
use Nette\Utils\Finder;
use Nette\Utils\Strings;
$directions = ['nahoru' => true, 'dolù' => false, 'doleva' => true, 'doprava' => false];
//true øíká, zda je cílová buòka sudá
/** @var \SplFileInfo $colorDirectory */
foreach (Finder::findDirectories('*')->from(__DIR__ . '/imagesOld') as $colorDirectory) {
\Nette\Utils\FileSystem::createDir(__DIR__ . '/imagesNew/' . $colorDirectory->getBasename());
$directionImages = [];
$directionImages['startCell'] = [];
$startCellImages = [];
$directionImages['targetCell'] = [];
$targetCellImages = [];
foreach (array_keys($directions) as $direction) {
$directionImages['startCell'][$direction] = [];
$directionImages['targetCell'][$direction] = [];
}
/** @var \SplFileInfo $image */
foreach (Finder::find('*')->from($colorDirectory->getPathname()) as $image) {
// echo $image->getPathname() . PHP_EOL;
foreach ($directions as $direction => $isTargetEven) {
//rozlišení smìru
if (Strings::contains($image->getBasename(), $direction)) {
示例12: getBowerDir
/**
* Determines Bower components directory.
* @return string
*/
private function getBowerDir()
{
// Load from configuration
if (isset($this->config['directory'])) {
return $this->config['directory'];
}
// Find .bowerrc
$bowerrcs = Finder::findFiles('.bowerrc')->in(array($this->containerBuilder->parameters['wwwDir'], $this->containerBuilder->parameters['wwwDir'] . '/..'));
foreach ($bowerrcs as $rc => $spl) {
try {
$bowerrc = Json::decode(@file_get_contents($rc));
if (isset($bowerrc->directory)) {
return dirname($rc) . '/' . $bowerrc->directory;
}
} catch (JsonException $e) {
throw new BowerLoaderException("Error while loading '{$rc}'", NULL, $e);
}
}
// Find bower_components
$directories = Finder::findDirectories('bower_components')->in(array($this->containerBuilder->parameters['wwwDir'], $this->containerBuilder->parameters['wwwDir'] . '/..'));
foreach ($directories as $directory => $spl) {
return $directory;
}
}
示例13: getSubdirectories
/**
* @return Nette\Utils\Finder
*/
public function getSubdirectories()
{
if ($this->subdirs === NULL) {
$this->subdirs = Nette\Utils\Finder::findDirectories('*')->from($this->getRoot());
}
return $this->subdirs;
}
示例14: findModules
/**
* Find all modules in filesystem.
*
* @return IModule[]
*/
public function findModules()
{
if ($this->_findModules === NULL) {
$this->_findModules = array();
foreach (Finder::findDirectories('*')->in($this->libsDir) as $dir) {
foreach (Finder::findDirectories('*')->in($dir) as $dir2) {
foreach (self::$moduleFiles as $moduleFile) {
foreach (Finder::findFiles($moduleFile)->in($dir2) as $file) {
$this->findModulesClosure($file);
}
}
}
}
foreach (Finder::findDirectories('*')->in($this->modulesDir) as $dir2) {
foreach (self::$moduleFiles as $moduleFile) {
foreach (Finder::findFiles($moduleFile)->in($dir2) as $file) {
$this->findModulesClosure($file);
}
}
}
}
return $this->_findModules;
}
示例15: foreach
<?php
/**
* Created by PhpStorm.
* User: Azathoth
* Date: 11. 1. 2016
* Time: 15:30
*/
require_once 'vendor/autoload.php';
use Nette\Utils\Finder;
use Nette\Utils\Strings;
/** @var \SplFileInfo $file */
foreach (Finder::findFiles('dolù*')->from(__DIR__ . '/imagesNew') as $file) {
echo $file->getBasename() . PHP_EOL;
\Nette\Utils\FileSystem::rename($file->getPathname(), Strings::replace($file->getPathname(), '~ù~', 'u'));
}
$translateColors = ['FIALOVÝ' => 'violet', 'ZELENEJ' => 'green', 'MODREJ' => 'blue', 'ÈERVENÝ' => 'red', 'ÈERNEJ' => 'black'];
foreach ($translateColors as $czech => $english) {
/** @var \SplFileInfo $file */
foreach (Finder::findDirectories("{$czech}*")->from(__DIR__ . '/imagesNew') as $file) {
echo $file->getBasename() . PHP_EOL;
\Nette\Utils\FileSystem::rename($file->getPathname(), Strings::replace($file->getPathname(), "~{$czech}~", $english));
}
}