本文整理汇总了PHP中Symfony\Component\Finder\Finder::notName方法的典型用法代码示例。如果您正苦于以下问题:PHP Finder::notName方法的具体用法?PHP Finder::notName怎么用?PHP Finder::notName使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Symfony\Component\Finder\Finder
的用法示例。
在下文中一共展示了Finder::notName方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: findFiles
/**
* @return array
*/
public function findFiles()
{
$files = array();
$finder = new Finder();
$iterate = false;
$finder->ignoreUnreadableDirs();
foreach ($this->items as $item) {
if (!is_file($item)) {
$finder->in($item);
$iterate = true;
} else {
$files[] = realpath($item);
}
}
foreach ($this->excludes as $exclude) {
$finder->exclude($exclude);
}
foreach ($this->names as $name) {
$finder->name($name);
}
foreach ($this->notNames as $notName) {
$finder->notName($notName);
}
foreach ($this->regularExpressionsExcludes as $regularExpressionExclude) {
$finder->notPath($regularExpressionExclude);
}
if ($iterate) {
foreach ($finder as $file) {
$files[] = $file->getRealpath();
}
}
return $files;
}
示例2: testNotName
public function testNotName()
{
$finder = new Finder();
$this->assertSame($finder, $finder->notName('*.php'));
$this->assertIterator($this->toAbsolute(array('foo', 'foo/bar.tmp', 'test.py', 'toto')), $finder->in(self::$tmpDir)->getIterator());
$finder = new Finder();
$finder->notName('*.php');
$finder->notName('*.py');
$this->assertIterator($this->toAbsolute(array('foo', 'foo/bar.tmp', 'toto')), $finder->in(self::$tmpDir)->getIterator());
$finder = new Finder();
$finder->name('test.ph*');
$finder->name('test.py');
$finder->notName('*.php');
$finder->notName('*.py');
$this->assertIterator(array(), $finder->in(self::$tmpDir)->getIterator());
}
示例3: withFilters
/**
* @param array $filters
* @return $this
*/
public function withFilters(array $filters)
{
if (!empty($filters)) {
foreach ($filters as $currentFilter) {
if (!strpos($currentFilter, ':')) {
throw new \InvalidArgumentException(sprintf('The filter "%s" is not a valid filter. A valid filter has the format <name>:<value>.', $currentFilter));
}
$currentFilterElements = explode(':', $currentFilter, 2);
switch (trim($currentFilterElements[0])) {
case 'exclude':
$this->finder->exclude($currentFilterElements[1]);
break;
case 'name':
$this->finder->name($currentFilterElements[1]);
break;
case 'notName':
$this->finder->notName($currentFilterElements[1]);
break;
case 'path':
$this->finder->path($currentFilterElements[1]);
break;
case 'size':
$this->finder->size($currentFilterElements[1]);
}
}
}
return $this;
}
示例4: execute
protected function execute(InputInterface $input, OutputInterface $output)
{
$output->writeln($this->getDescription() . PHP_EOL);
$target = $input->getArgument('target');
$sources = $this->createArrayBy($input->getOption('source'));
$excludes = $this->createArrayBy($input->getOption('exclude'));
$noComments = (bool) $input->getOption('nocomments');
$this->writer->setTarget($target);
$this->finder->in($sources)->exclude($excludes);
if ($notName = $input->getOption('notname')) {
$this->finder->notName($notName);
}
$output->writeln(sprintf(Message::PROGRESS_FILTER, $this->finder->count()));
$classMap = $this->filter->extractClassMapFrom($this->finder->getIterator());
$output->writeln(sprintf(Message::PROGRESS_WRITE, $target));
$this->writer->minify($classMap, $noComments);
$output->writeln(PHP_EOL . Message::PROGRESS_DONE . PHP_EOL);
}
示例5: add
/**
*
* @param type $filepattern
* @param type $dir
* @param type $excludepattern
* @return \Awakenweb\Beverage\Beverage
*/
public function add($filepattern, $dir, $excludepattern)
{
$finder = new Finder();
$finder->files()->ignoreUnreadableDirs()->name($filepattern);
if ($excludepattern) {
$finder->notName($excludepattern);
}
foreach ($dir as $directory) {
$finder->in($directory);
}
foreach ($finder as $matching_file) {
$basename = $matching_file->getBasename();
$this->current_state[$basename] = $matching_file->getContents();
}
return $this;
}
示例6: run
public function run()
{
$files = [];
$this->console('<comment>Watch server running.</comment>');
do {
foreach ($this->files_iterators as $fi) {
$finder = new Finder();
$finder->files()->ignoreUnreadableDirs()->name($fi['filepattern']);
if ($fi['excludepattern']) {
$finder->notName($fi['excludepattern']);
}
foreach ($fi['dir'] as $directory) {
$finder->in($directory);
}
foreach ($finder as $file) {
/**
* Register the file the first time it is encountered
*/
if (!isset($files[$file->getBasename()])) {
$files[$file->getBasename()] = $file->getMTime();
}
/**
* Check if the file has changed
*/
if ($files[$file->getBasename()] !== $file->getMTime()) {
$this->console('File ' . $file->getBasename() . ' has been modified');
$files[$file->getBasename()] = $file->getMTime();
try {
$this->runBefore();
foreach ($fi['tasks'] as $task) {
$this->console('Running ' . $task . ' task');
$task();
$this->console('Task ' . $task . ' successful');
}
$this->runAfter();
} catch (\Exception $ex) {
$this->console("<error>An error occured when running the tasks.</error>");
}
}
}
unset($finder);
}
sleep(3);
} while (1);
}
示例7: _findFiles
private function _findFiles()
{
$finder = new Finder();
$finder->files();
foreach ($this->_excludePatterns as $excludePattern) {
$finder->notName($excludePattern);
}
foreach ($this->_paths as $p) {
$finder->in($p);
}
if ($this->_followLinks) {
$finder->followLinks();
}
$files = array();
foreach ($finder as $f) {
$files[$f->getRealpath()] = array('mtime' => $f->getMTime(), 'perms' => $f->getPerms(), 'owner' => $f->getOwner(), 'group' => $f->getGroup());
}
return $files;
}
示例8: registerCommands
/**
* {@inheritdoc}
*/
public function registerCommands(Application $application)
{
if (!is_dir($dir = $this->getPath() . '/Command')) {
return;
}
$finder = new Finder();
$finder->files()->name('*Command.php')->in($dir);
// Don't enable the generate command when SensioGeneratorBundle is not installed
if (!class_exists('Sensio\\Bundle\\GeneratorBundle\\Command\\GenerateBundleCommand')) {
$finder->notName('GenerateUserSysCommand.php');
}
$prefix = $this->getNamespace() . '\\Command';
foreach ($finder as $file) {
$ns = $prefix;
if ($relativePath = $file->getRelativePath()) {
$ns .= '\\' . strtr($relativePath, '/', '\\');
}
$class = $ns . '\\' . $file->getBasename('.php');
$r = new \ReflectionClass($class);
if ($r->isSubclassOf('Symfony\\Component\\Console\\Command\\Command') && !$r->isAbstract() && !$r->getConstructor()->getNumberOfRequiredParameters()) {
$application->add($r->newInstance());
}
}
}
示例9: getConfigFiles
/**
* @return array|\Iterator
*/
public function getConfigFiles()
{
try {
$f = new Finder();
$f->name('*.xml.skeleton');
$f->name('*.yml.skeleton');
$f->notName('*.orm.xml.skeleton');
$f->notName('*.orm.yml.skeleton');
$f->notPath('doctrine/');
$f->notPath('serializer/');
$f->in($this->getMappingConfigDirectory());
return $f->getIterator();
} catch (\Exception $e) {
return array();
}
}
示例10: _parseIterator
/**
* @param \DOMNode $node
* @return \Iterator|null
*/
protected function _parseIterator(DOMNode $node)
{
$finder = new Finder();
$finder->files();
foreach ($node->childNodes as $option) {
if ($option->nodeType === XML_ELEMENT_NODE) {
$nodeName = strtolower($option->nodeName);
$value = $option->nodeValue;
switch ($nodeName) {
case 'name':
$finder->name($value);
break;
case 'notname':
$finder->notName($value);
break;
case 'path':
$finder->in($value);
break;
case 'size':
$finder->size($value);
break;
case 'exclude':
$finder->exclude($value);
break;
}
}
}
return $finder->getIterator();
}
示例11: index
public function index()
{
/*
|--------------------------------------------------------------------------
| Paramers
|--------------------------------------------------------------------------
|
| Match overrides Extension. Exclusion applies in both cases.
|
*/
$match = $this->fetchParam('match', false);
$exclude = $this->fetchParam('exclude', false);
$extension = $this->fetchParam(array('extension', 'type'), false);
$in = $this->fetchParam(array('in', 'folder', 'from'), false);
$not_in = $this->fetchParam('not_in', false);
$file_size = $this->fetchParam('file_size', false);
$file_date = $this->fetchParam('file_date', false);
$depth = $this->fetchParam('depth', false);
$sort_by = $this->fetchParam(array('sort_by', 'order_by'), false);
$sort_dir = $this->fetchParam(array('sort_dir', 'sort_direction'), 'asc');
$limit = $this->fetchParam('limit', false);
if ($in) {
$in = Helper::explodeOptions($in);
}
if ($not_in) {
$not_in = Helper::explodeOptions($not_in);
}
if ($file_size) {
$file_size = Helper::explodeOptions($file_size);
}
if ($extension) {
$extension = Helper::explodeOptions($extension);
}
/*
|--------------------------------------------------------------------------
| Finder
|--------------------------------------------------------------------------
|
| Get_Files implements most of the Symfony Finder component as a clean
| tag wrapper mapped to matched filenames.
|
*/
$finder = new Finder();
if ($in) {
foreach ($in as $location) {
$finder->in(Path::fromAsset($location));
}
}
/*
|--------------------------------------------------------------------------
| Name
|--------------------------------------------------------------------------
|
| Match is the "native" Finder name() method, which is supposed to
| implement string, glob, and regex. The glob support is only partial,
| so "extension" is a looped *single* glob rule iterator.
|
*/
if ($match) {
$finder->name($match);
} elseif ($extension) {
foreach ($extension as $ext) {
$finder->name("*.{$ext}");
}
}
/*
|--------------------------------------------------------------------------
| Exclude
|--------------------------------------------------------------------------
|
| Exclude directories from matching. Remapped to "not in" to allow more
| intuitive differentiation between filename and directory matching.
|
*/
if ($not_in) {
foreach ($not_in as $location) {
$finder->exclude($location);
}
}
/*
|--------------------------------------------------------------------------
| Not Name
|--------------------------------------------------------------------------
|
| Exclude files matching a given pattern: string, regex, or glob.
| By default we don't allow looking for PHP files. Be smart.
|
*/
if ($this->fetchParam('allow_php', false) !== TRUE) {
$finder->notName("*.php");
}
if ($exclude) {
$finder->notName($exclude);
}
/*
|--------------------------------------------------------------------------
| File Size
|--------------------------------------------------------------------------
|
| Restrict files by size. Can be chained and allows comparison operators.
//.........这里部分代码省略.........
示例12: getAllFiles
/**
* Lista carpeta y archivos segun el path ingresado, no recursivo, ordenado por tipo y nombre
*
* @param string $path Ruta de la carpeta o archivo
* @return array|null Listado de archivos o null si no existe
*/
public function getAllFiles($path)
{
$fullpath = $this->getFullPath() . $path;
if (file_exists($fullpath)) {
$file = new \SplFileInfo($fullpath);
if ($file->isDir()) {
$r = array();
// if($path != "/") $r[] = $this->folderParent($path);
$finder = new Finder();
$directories = $finder->notName('_thumbs')->notName('web.config')->notName('.htaccess')->depth(0)->sortByType();
// $directories = $directories->files()->name('*.jpg');
$directories = $directories->in($fullpath);
foreach ($directories as $key => $directorie) {
$namefile = $directorie->getFilename();
if ($directorie->isDir() && $this->validNameFile($namefile, false)) {
$t = $this->fileInfo($directorie, $path);
if ($t) {
$r[] = $t;
}
} elseif ($directorie->isFile() && $this->validNameFile($namefile)) {
$t = $this->fileInfo($directorie, $path);
if ($t) {
$r[] = $t;
}
}
}
return $r;
} elseif ($file->isFile()) {
$t = $this->fileInfo($file, $path);
if ($t) {
return $t;
} else {
$result = array("query" => "BE_GETFILEALL_NOT_LEIBLE", "params" => array());
$this->setInfo(array("msg" => $result));
if ($this->config['debug']) {
$this->_log(__METHOD__ . " - Archivo no leible - {$fullpath}");
}
return;
}
} elseif ($file->isLink()) {
$result = array("query" => "BE_GETFILEALL_NOT_PERMITIDO", "params" => array());
$this->setInfo(array("msg" => $result));
if ($this->config['debug']) {
$this->_log(__METHOD__ . " - path desconocido - {$fullpath}");
}
return;
}
} else {
$result = array("query" => "BE_GETFILEALL_NOT_EXISTED", "params" => array());
$this->setInfo(array("msg" => $result));
if ($this->config['debug']) {
$this->_log(__METHOD__ . " - No existe el archivo - {$fullpath}");
}
return;
}
}
示例13: cleanCustom
/**
* @param OutputInterface $output
* @return void
*/
protected function cleanCustom(OutputInterface $output)
{
if (empty($this->options['custom'])) {
return;
}
foreach ($this->options['custom'] as $options) {
try {
$finder = new Finder();
$finder->ignoreDotFiles(false);
$finder->ignoreVCS(false);
$finder->ignoreUnreadableDirs(true);
$in = [];
if (!is_array($options['in'])) {
$options['in'] = [$options['in']];
}
foreach ($options['in'] as $dir) {
$in[] = $this->baseDir . $dir;
}
$finder->in($in);
if (!empty($options['type'])) {
switch ($options['type']) {
case 'files':
$finder->files();
break;
case 'dirs':
case 'directories':
$finder->directories();
break;
}
}
if (!empty($options['notName'])) {
if (!is_array($options['notName'])) {
$options['notName'] = [$options['notName']];
}
foreach ($options['notName'] as $notName) {
$finder->notName($notName);
}
}
if (!empty($options['name'])) {
if (!is_array($options['name'])) {
$options['name'] = [$options['name']];
}
foreach ($options['name'] as $notName) {
$finder->name($notName);
}
}
if (!empty($options['depth'])) {
$finder->depth($options['depth']);
}
foreach ($finder as $file) {
$this->files[] = $file->getRealPath();
}
} catch (\Exception $e) {
// ignore errors
}
}
}
示例14: findFiles
/**
* Find all files to merge.
*
* @param string $directory
* @param array $names
* @param array $ignoreNames
*
* @return Finder
*/
private function findFiles($directory, array $names, array $ignoreNames)
{
$finder = new Finder();
$finder->files()->in($directory);
foreach ($names as $name) {
$finder->name($name);
}
foreach ($ignoreNames as $name) {
$finder->notName($name);
}
$finder->sortByName();
return $finder;
}
示例15: getFiles
/**
* Get a list of plugin files.
*
* @param Finder $finder The finder to use, can be pre-configured
*
* @return array Of files
*/
public function getFiles(Finder $finder)
{
$finder->files()->in($this->directory)->ignoreUnreadableDirs();
// Ignore third party libraries.
foreach ($this->getThirdPartyLibraryPaths() as $libPath) {
$finder->notPath($libPath);
}
// Extra ignores for CI.
$ignores = $this->getIgnores();
if (!empty($ignores['notPaths'])) {
foreach ($ignores['notPaths'] as $notPath) {
$finder->notPath($notPath);
}
}
if (!empty($ignores['notNames'])) {
foreach ($ignores['notNames'] as $notName) {
$finder->notName($notName);
}
}
$files = [];
foreach ($finder as $file) {
/* @var \SplFileInfo $file */
$files[] = $file->getRealpath();
}
return $files;
}