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


PHP Finder::notPath方法代码示例

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


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

示例1: createMap

 /**
  * Create a map for a given path
  *
  * @param array $paths
  * @return array
  */
 public function createMap(...$paths)
 {
     $classes = [];
     $this->finder->files()->ignoreUnreadableDirs()->in($paths);
     foreach ($this->excludePathPatterns as $exclude) {
         $this->finder->notPath($exclude);
     }
     foreach ($this->inPathPatterns as $inPath) {
         $this->finder->path($inPath);
     }
     foreach ($this->names as $name) {
         $this->finder->name($name);
     }
     /** @var SplFileInfo $file */
     foreach ($this->finder as $file) {
         $content = file_get_contents($file->getPathname());
         preg_match('^\\s*class ([\\S]*)\\s*(extends|implements|{)^', $content, $match, PREG_OFFSET_CAPTURE);
         if (isset($match[1])) {
             $className = '\\' . trim($match[1][0]);
             $offset = $match[1][1];
         } else {
             continue;
         }
         preg_match('|\\s*namespace\\s*([\\S]*)\\s*;|', substr($content, 0, $offset), $match);
         if (isset($match[1]) && trim($match[1]) !== '') {
             $className = '\\' . trim($match[1]) . $className;
         }
         if ($className !== '\\') {
             $classes[$file->getPathname()] = $className;
         }
     }
     return $classes;
 }
开发者ID:AValnar,项目名称:FileToClassMapper,代码行数:39,代码来源:Mapper.php

示例2: followLinks

 public static function followLinks(array $paths, $excludePatterns)
 {
     $finder = new Finder();
     $finder->directories();
     foreach ($excludePatterns as $excludePattern) {
         if (substr($excludePattern, 0, 1) == '/') {
             $excludePattern = substr($excludePattern, 1);
         }
         $excludePattern = '/' . preg_quote($excludePattern, '/') . '/';
         $excludePattern = str_replace(preg_quote('*', '/'), '.*', $excludePattern);
         $finder->notPath($excludePattern);
     }
     foreach ($paths as $p) {
         $finder->in($p);
     }
     foreach ($finder as $i) {
         if ($i->isLink()) {
             $realPath = $i->getRealPath();
             foreach ($paths as $k => $p2) {
                 if (substr($realPath, 0, strlen($p2) + 1) == $p2 . '/') {
                     continue 2;
                 }
             }
             $paths[] = $realPath;
         }
     }
     return $paths;
 }
开发者ID:koala-framework,项目名称:file-watcher,代码行数:28,代码来源:Links.php

示例3: 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;
 }
开发者ID:klikar3,项目名称:yii2-RGraph,代码行数:36,代码来源:FinderFacade.php

示例4: appendDetectionCriteria

 /**
  * TYPO3 has a file called LocalConfiguration.php or localconf.php that can be used to search for working installations
  *
  * @param   Finder  $finder  finder instance to append the criteria
  *
  * @return  Finder
  */
 public function appendDetectionCriteria(Finder $finder)
 {
     $finder->name('LocalConfiguration.php');
     $finder->name('localconf.php');
     // always skip typo3temp as it may contain leftovers from functional tests
     $finder->notPath('typo3temp');
     return $finder;
 }
开发者ID:antondollmaier,项目名称:cmsscanner,代码行数:15,代码来源:Typo3CmsAdapter.php

示例5: doAddPattern

 /**
  * Action for Add an ignore pattern.
  *
  * @param string $pattern The pattern
  */
 public function doAddPattern($pattern)
 {
     if (0 === strpos($pattern, '!')) {
         $this->finder->notPath(Glob::toRegex(substr($pattern, 1), true, false));
     } else {
         $this->finder->path(Glob::toRegex($pattern, true, false));
     }
 }
开发者ID:pombredanne,项目名称:ArcherSys,代码行数:13,代码来源:IgnoreManager.php

示例6: convertPatternStep2

 /**
  * Step2: Converter pattern to glob.
  *
  * @param string $prefix        The prefix
  * @param string $searchPattern The search pattern
  * @param string $pattern       The pattern
  */
 protected function convertPatternStep2($prefix, $searchPattern, $pattern)
 {
     if ('.*' === $searchPattern) {
         $this->doAddPattern($prefix . '**/.*');
     } elseif ('**' === $searchPattern) {
         $this->finder->path('/.*/');
         $this->finder->notPath('/^\\..*(?!\\/)/');
     } elseif (preg_match('/\\/\\*$|\\/\\*\\*$/', $pattern, $matches)) {
         $this->doAddPattern(substr($pattern, 0, strlen($pattern) - strlen($matches[0])));
     }
 }
开发者ID:stefangr,项目名称:composer-asset-plugin,代码行数:18,代码来源:IgnoreManager.php

示例7: getFiles

 public function getFiles()
 {
     $files = new Finder();
     $files->files()->in(realpath($this->path));
     foreach ($this->excludes as $exclude) {
         $files->notPath($exclude);
     }
     foreach ($this->extensions as $extension) {
         $files->name('*.' . $extension);
     }
     return iterator_to_array($files);
 }
开发者ID:watsonad,项目名称:opendocman,代码行数:12,代码来源:Linter.php

示例8: getItems

 public function getItems(array $include, array $exclude)
 {
     $finder = new Finder();
     $finder->in($this->getRootPath());
     foreach ($include as $path) {
         $finder->path($this->normalizePath($path));
     }
     foreach ($exclude as $path) {
         $finder->notPath($this->normalizePath($path));
     }
     $items = [];
     foreach ($finder as $resource) {
         $items[] = $this->loadItem($resource);
     }
     return $items;
 }
开发者ID:jmfontaine,项目名称:projectlint,代码行数:16,代码来源:ItemManager.php

示例9: get_files

 /**
  * Returns a Finder instance for the files that will be included in the
  * backup.
  *
  * By default we ignore unreadable files and directories as well as, common
  * version control folders / files, "Dot" files and anything matching the
  * exclude rules.
  *
  * @uses Finder
  * @return Finder The Finder iterator of all files to be included
  */
 public function get_files()
 {
     $finder = new Finder();
     $finder->followLinks(true);
     $finder->ignoreDotFiles(false);
     $finder->ignoreVCS(true);
     $finder->ignoreUnreadableDirs(true);
     // Skip unreadable files too
     $finder->filter(function (\SplFileInfo $file) {
         if (!$file->isReadable()) {
             return false;
         }
     });
     // Finder expects exclude rules to be in a regex format
     $exclude_rules = $this->excludes->get_excludes_for_regex();
     // Skips folders/files that match default exclude patterns
     foreach ($exclude_rules as $exclude) {
         $finder->notPath($exclude);
     }
     return $finder->in(Path::get_root());
 }
开发者ID:AcademicTechnologyCenter,项目名称:ATC-Quality-Tracking,代码行数:32,代码来源:class-backup-engine-file.php

示例10: createFinder

 /**
  * @param  InputInterface $input
  * @return Finder
  */
 public function createFinder(InputInterface $input)
 {
     $finder = new Finder();
     $finder->files();
     foreach ($input->getArgument('directory') as $dir) {
         $finder->in($dir);
     }
     foreach ($input->getOption('not-dir') as $ignoreDir) {
         $finder->exclude($ignoreDir);
     }
     foreach ($input->getOption('file-name') as $pattern) {
         $finder->name($pattern);
     }
     foreach ($input->getOption('not-file-name') as $pattern) {
         $finder->notName($pattern);
     }
     foreach ($input->getOption('contains') as $pattern) {
         $finder->contains($pattern);
     }
     foreach ($input->getOption('not-contains') as $pattern) {
         $finder->notContains($pattern);
     }
     foreach ($input->getOption('path') as $pattern) {
         $finder->path($pattern);
     }
     foreach ($input->getOption('not-path') as $pattern) {
         $finder->notPath($pattern);
     }
     if ($size = $input->getOption('size')) {
         $finder->size($size);
     }
     if ($modified = $input->getOption('modified')) {
         $finder->date($modified);
     }
     if ($depth = $input->getOption('depth')) {
         $finder->depth($depth);
     }
     return $finder;
 }
开发者ID:hanneskod,项目名称:phpfind,代码行数:43,代码来源:Command.php

示例11: getRepositoryFinder

 /**
  * @param string $root
  * @param string $virtualHost
  * @param array $settings
  * @param string|null $repository
  * @return Finder
  */
 protected function getRepositoryFinder($root, $virtualHost, array $settings, $repository = null)
 {
     $root = rtrim($root, '/\\');
     $virtualHost = trim($virtualHost, '/\\');
     $absolutePath = $root . DIRECTORY_SEPARATOR . $virtualHost;
     if (!@is_dir($absolutePath)) {
         throw new \InvalidArgumentException('Wrong path provided', 1456264866695);
     }
     if (!isset($settings['default']['show']['depth'])) {
         throw new \InvalidArgumentException('Missing default repository configuration', 1456425560002);
     }
     $depth = $settings['default']['show']['depth'];
     if (isset($settings[$virtualHost]['show']['depth'])) {
         $depth = $settings[$virtualHost]['show']['depth'];
     }
     $finder = new Finder();
     $finder->directories()->ignoreUnreadableDirs(true)->ignoreDotFiles(false)->ignoreVCS(false)->followLinks()->name('.git')->depth($depth)->sort(function (SplFileInfo $a, SplFileInfo $b) {
         return strcmp($a->getRelativePathname(), $b->getRelativePathname());
     })->in($absolutePath);
     $excludeDirs = null;
     if (isset($settings['default']['show']['exclude'])) {
         $excludeDirs = $settings['default']['show']['exclude'];
     }
     if (isset($settings[$virtualHost]['show']['exclude'])) {
         $excludeDirs = $settings[$virtualHost]['show']['exclude'];
     }
     if (!empty($excludeDirs) && is_array($excludeDirs)) {
         foreach ($excludeDirs as $dir) {
             $finder->notPath(strtr($dir, '\\', '/'));
         }
     }
     if ($repository) {
         $repository = trim($repository, '/\\');
         $absolutePath .= DIRECTORY_SEPARATOR . $repository;
         if (!@is_dir($absolutePath)) {
             throw new \InvalidArgumentException('Wrong repository path provided', 1456433944431);
         }
         $finder->depth(0)->in($absolutePath);
         if (count($finder) !== 1) {
             throw new \RuntimeException('Unexpected repository count found', 1456433999553);
         }
     }
     return $finder;
 }
开发者ID:ichhabrecht,项目名称:git-checker,代码行数:51,代码来源:DirectoryController.php

示例12: finder

 /**
  * Build a Symfony Finder object that scans the given $directory.
  *
  * @param string|array|Finder $directory The directory(s) or filename(s)
  * @param null|string|array $exclude The directory(s) or filename(s) to exclude (as absolute or relative paths)
  * @throws InvalidArgumentException
  */
 public static function finder($directory, $exclude = null)
 {
     if ($directory instanceof Finder) {
         return $directory;
     } else {
         $finder = new Finder();
         $finder->sortByName();
     }
     $finder->files();
     if (is_string($directory)) {
         if (is_file($directory)) {
             // Scan a single file?
             $finder->append([$directory]);
         } else {
             // Scan a directory
             $finder->in($directory);
         }
     } elseif (is_array($directory)) {
         foreach ($directory as $path) {
             if (is_file($path)) {
                 // Scan a file?
                 $finder->append([$path]);
             } else {
                 $finder->in($path);
             }
         }
     } else {
         throw new InvalidArgumentException('Unexpected $directory value:' . gettype($directory));
     }
     if ($exclude !== null) {
         if (is_string($exclude)) {
             $finder->notPath(Util::getRelativePath($exclude, $directory));
         } elseif (is_array($exclude)) {
             foreach ($exclude as $path) {
                 $finder->notPath(Util::getRelativePath($path, $directory));
             }
         } else {
             throw new InvalidArgumentException('Unexpected $exclude value:' . gettype($exclude));
         }
     }
     return $finder;
 }
开发者ID:biberlabs,项目名称:mocker,代码行数:49,代码来源:Util.php

示例13: getSysFiles

 /**
  * @return Finder
  */
 public function getSysFiles()
 {
     $finder = new Finder();
     $sysPath = $this->getSysPath();
     $finder->files()->in($sysPath);
     $finder->notPath('vendor');
     $finder->notPath('tests');
     return $finder;
 }
开发者ID:ilosada,项目名称:chamilo-lms-icpna,代码行数:12,代码来源:ConfigurationHelper.php

示例14: copyRestToDestination

 /**
  * Copy the rest files to destination
  * 
  * @return array Filenames affected
  */
 public function copyRestToDestination()
 {
     $fs = new Filesystem();
     $result = array();
     $includedFiles = array();
     $dir = $this->getSourceDir();
     $include = $this->configuration->getRepository()->get('include');
     $exclude = $this->configuration->getRepository()->get('exclude');
     $processableExt = $this->getProcessableExtention();
     $finder = new Finder();
     $finder->in($dir)->exclude($this->getSpecialDir());
     $finder->notName($this->configuration->getConfigFilename());
     $finder->notName($this->configuration->getConfigEnvironmentFilenameWildcard());
     $finder->notName($this->fileExtToRegExpr($processableExt));
     foreach ($include as $item) {
         if (is_dir($item)) {
             $finder->in($item);
         } else {
             if (is_file($item) && !in_array(pathinfo($item, PATHINFO_EXTENSION), $processableExt)) {
                 $includedFiles[] = new SplFileInfo($this->resolvePath($item), "", pathinfo($item, PATHINFO_BASENAME));
             }
         }
     }
     foreach ($exclude as $item) {
         $finder->notPath($item);
     }
     $finder->append($includedFiles);
     foreach ($finder as $file) {
         if ($file->isDir()) {
             $this->mkDirIfNotExists($this->getDestinationDir() . '/' . $file->getRelativePath());
         } else {
             if ($file->isFile()) {
                 $result[] = $file->getRealpath();
                 $fs->copy($file->getRealpath(), $this->getDestinationDir() . '/' . $file->getRelativePathname());
             }
         }
     }
     return $result;
 }
开发者ID:pancao,项目名称:Spress,代码行数:44,代码来源:ContentLocator.php

示例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;
 }
开发者ID:gjb2048,项目名称:moodle-plugin-ci,代码行数:33,代码来源:MoodlePlugin.php


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