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


PHP Finder::exclude方法代码示例

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


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

示例1: 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;
 }
开发者ID:suralc,项目名称:pvra,代码行数:32,代码来源:FileFinderBuilder.php

示例2: execute

 /**
  * @param InputInterface $input
  * @param OutputInterface $output
  * @return int|null|void
  * @throws \RuntimeException
  */
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $commandConfig = $this->getCommandConfig();
     $this->detectMagento($output);
     $finder = new Finder();
     $finder->files()->followLinks(true)->in($this->getApplication()->getMagentoRootFolder() . DIRECTORY_SEPARATOR . 'media');
     if ($input->getOption('strip')) {
         $finder->exclude($commandConfig['strip']['folders']);
     }
     $filename = (string) $input->getArgument('filename');
     if (is_dir($filename)) {
         // support for dot dir
         $filename = realpath($filename);
         $filename .= '/';
     }
     if (empty($filename) || is_dir($filename)) {
         $filename .= 'media_' . date('Ymd_his') . '.zip';
     }
     $zip = new \ZipArchive();
     $zip->open($filename, \ZIPARCHIVE::CREATE);
     $zip->addEmptyDir('media');
     $lastFolder = '';
     foreach ($finder as $file) {
         /* @var $file SplFileInfo */
         $currentFolder = pathinfo($file->getRelativePathname(), PATHINFO_DIRNAME);
         if ($currentFolder != $lastFolder) {
             $output->writeln(sprintf('<info>Compress directory:</info> <comment>media/%s</comment>', $currentFolder));
         }
         $zip->addFile($file->getPathname(), 'media' . DIRECTORY_SEPARATOR . $file->getRelativePathname());
         $lastFolder = $currentFolder;
     }
     $zip->close();
 }
开发者ID:navarr,项目名称:n98-magerun,代码行数:39,代码来源:DumpCommand.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:sakshika,项目名称:ATM,代码行数:36,代码来源:FinderFacade.php

示例4: getFinder

 /**
  *
  * @param string $path        	
  * @return \Symfony\Component\Finder\Finder
  */
 protected function getFinder($path)
 {
     $finder = new Finder();
     $finder->ignoreDotFiles(TRUE);
     $finder->depth(0);
     $finder->exclude($this->excludeDirs);
     if (!is_dir($path)) {
         return $finder;
     }
     $finder->in($path);
     return $finder;
 }
开发者ID:slavomirkuzma,项目名称:itc-bundle,代码行数:17,代码来源:PHPCRController.php

示例5: doExecute

 protected function doExecute(InputInterface $input, OutputInterface $output)
 {
     $finder = new Finder();
     $in = $this->container['cache.paths']->getArrayCopy();
     $finder->exclude('.git')->exclude('.svn')->in($in);
     $this->container['filesystem']->remove($finder);
     if ($this->container['phraseanet.configuration-tester']->isInstalled()) {
         $this->getService('phraseanet.cache-service')->flushAll();
     }
     $output->write('Finished !', true);
     return 0;
 }
开发者ID:luisbrito,项目名称:Phraseanet,代码行数:12,代码来源:systemClearCache.php

示例6: doExecute

 protected function doExecute(InputInterface $input, OutputInterface $output)
 {
     $finder = new Finder();
     $finder->exclude('.git')->exclude('.svn')->in([$this->container['root.path'] . '/tmp/cache_minify/', $this->container['root.path'] . '/tmp/cache_twig/', $this->container['root.path'] . '/tmp/translations/', $this->container['root.path'] . '/tmp/cache/profiler/', $this->container['root.path'] . '/tmp/doctrine/', $this->container['root.path'] . '/tmp/serializer/']);
     $filesystem = new Filesystem();
     $filesystem->remove($finder);
     if ($this->container['phraseanet.configuration-tester']->isInstalled()) {
         $this->getService('phraseanet.cache-service')->flushAll();
     }
     $output->write('Finished !', true);
     return 0;
 }
开发者ID:romainneutron,项目名称:Phraseanet,代码行数:12,代码来源:systemClearCache.php

示例7: clearAssets

 /**
  * Clear all the compiled assets.
  *
  * @param  bool  $clean
  * @return void
  */
 public function clearAssets($clear = false)
 {
     if ($clear) {
         $path = $this->locationGenerator->getPublicPath($this->cachePath);
         $finder = new Finder();
         $finder->in($path);
         $finder->exclude(array('.gitignore'));
         $files = array();
         foreach ($finder->files() as $file) {
             $files[] = $path . DIRECTORY_SEPARATOR . $file->getRelativePathname();
         }
         with(new Filesystem())->remove($files);
     }
 }
开发者ID:sohailaammarocs,项目名称:lfc,代码行数:20,代码来源:AssetManager.php

示例8: extractThemeGenerators

 /**
  * @param $directory
  * @param $source
  */
 private function extractThemeGenerators($directory, $source)
 {
     $finder = new Finder();
     $finder->files()->name('*Generator.php')->in($directory)->depth('< 2');
     $finder->exclude('Exclude');
     if (!$this->develop) {
         $finder->exclude('Develop');
     }
     foreach ($finder as $file) {
         $className = sprintf('Drupal\\%s\\Generator\\%s', $source, str_replace(['/', '.php'], ['\\', ''], $file->getRelativePathname()));
         include $file->getPathname();
     }
 }
开发者ID:kgaut,项目名称:DrupalConsole,代码行数:17,代码来源:CommandDiscoveryHelper.php

示例9: execute

 /**
  * Executes the current command.
  *
  * @param InputInterface  $input  An InputInterface instance
  * @param OutputInterface $output An OutputInterface instance
  *
  * @return null|int     null or 0 if everything went fine, or an error code
  */
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $output->writeln('');
     $output->writeln('<comment>Creating package</comment>');
     $this->validate($input, $output);
     try {
         //get all params
         $rutaPhar = $input->getOption('output');
         $alias = $input->getOption('alias') . '.phar';
         $rutaPhar = rtrim($rutaPhar, '/') . '/' . $alias;
         $src = $input->getOption('src');
         $stub = $input->getOption('stub');
         $stubweb = $input->getOption('stubweb');
         $replace = $input->getOption('replace');
         $exclude = $input->getOption('exclude');
         if (true === $replace && is_file($rutaPhar)) {
             \Phar::unlinkArchive($rutaPhar);
         }
         //create and setup Stup object
         $oStub = new Stub();
         if (null !== $stub) {
             $oStub->setStubCli($stub);
         }
         if (null !== $stubweb) {
             $oStub->setStubWeb($stubweb);
         }
         $oStub->setDirTmp($src);
         $oStub->createDefaultStub();
         //create Finder object
         $finder = new Finder();
         $finder->files()->in($src);
         foreach ($exclude as $dirToExclude) {
             $finder->exclude($dirToExclude);
         }
         //inicialize progressbar
         $progress = new ProgressBar($output, count($finder));
         //create phar object
         $phar = new \Phar($rutaPhar, 0, $alias);
         $phar->startBuffering();
         //create default stubs
         $phar->setStub($phar->createDefaultStub($oStub->getStubCli(), $oStub->getStubWeb()));
         $progress->setBarCharacter('<comment>=</comment>');
         $progress->setProgressCharacter('<comment>></comment>');
         //add all files in the phar object
         $progress->start();
         foreach ($finder as $file) {
             $alias = ltrim(str_replace($src, '', $file->getPathname()), '/');
             $phar->addFile($file, $alias);
             $progress->advance();
         }
         $progress->finish();
         $phar->stopBuffering();
         $oStub->deleteTmpStubs();
         $output->writeln('');
         $output->writeln('');
         $output->writeln("<info>Phar created in: </info>" . $rutaPhar);
     } catch (\Exception $e) {
         $output->writeln('<error>' . $e->getMessage() . "</error>");
         exit(1);
     }
 }
开发者ID:mostofreddy,项目名称:phox,代码行数:69,代码来源:Building.php

示例10: getFiles

 /**
  * Get suite files with tests.
  *
  * @return \ArrayObject
  */
 public function getFiles()
 {
     if ($this->files === null) {
         $files = new \ArrayObject();
         foreach ($this->config['source'] as $source) {
             $finder = new Finder();
             $finder->ignoreUnreadableDirs()->files();
             $finder->in($source['in'])->name($source['name']);
             if (!empty($source['notName'])) {
                 foreach ($source['notName'] as $name) {
                     $finder->notName($name);
                 }
             }
             if (!empty($source['exclude'])) {
                 $finder->exclude($source['exclude']);
             }
             /** @var \SplFileInfo $file */
             foreach ($finder as $file) {
                 $realPath = $file->getRealPath();
                 if (!$files->offsetExists($realPath) && substr($file->getFilename(), -8) === 'Test.php') {
                     $files[$realPath] = $file;
                 }
             }
         }
         $this->files = $files;
     }
     return $this->files;
 }
开发者ID:komex,项目名称:unteist,代码行数:33,代码来源:Configurator.php

示例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('extension', false);
     $in = $this->fetchParam('in', 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);
     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();
     $finder->in($in);
     // Finder doesn't respect multiple glob options,
     // so this will need to wait until later.
     //
     // $match = str_replace('{{', '{', $match);
     // $match = str_replace('}}', '}', $match);
     /*
     |--------------------------------------------------------------------------
     | 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) {
         $finder->exclude($not_in);
     }
     /*
     |--------------------------------------------------------------------------
     | Not Name
     |--------------------------------------------------------------------------
     |
     | Exclude files matching a given pattern: string, regex, or glob.
     |
     */
     if ($exclude) {
         $finder->notName($exclude);
     }
     /*
     |--------------------------------------------------------------------------
     | File Size
     |--------------------------------------------------------------------------
     |
     | Restrict files by size. Can be chained and allows comparison operators.
     |
     */
     if ($file_size) {
         foreach ($file_size as $size) {
             $finder->size($size);
         }
     }
     /*
     |--------------------------------------------------------------------------
     | File Date
     |--------------------------------------------------------------------------
     |
     | Restrict files by last modified date. Can use comparison operators, and
     | since/after is aliased to >, and until/before to <.
//.........这里部分代码省略.........
开发者ID:nob,项目名称:joi,代码行数:101,代码来源:pi.get_files.php

示例12: _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();
 }
开发者ID:robo47,项目名称:php-manipulator,代码行数:33,代码来源:Xml.php

示例13: exclude

 /**
  * @return Finder
  */
 public function exclude($dirs)
 {
     return parent::exclude($dirs);
 }
开发者ID:stopsopa,项目名称:utils,代码行数:7,代码来源:Finder.php

示例14: prepareFinder

 protected function prepareFinder($directories, $excludes, array $names = null)
 {
     $finder = new Finder();
     $finder->files();
     if (!is_null($names) && count($names) > 0) {
         foreach ($names as $name) {
             $finder->name($name);
         }
     } else {
         $finder->name('*.php');
     }
     if ($directories) {
         foreach ($directories as $directory) {
             $finder->in($directory);
         }
     } else {
         $finder->in('.');
     }
     if (isset($excludes)) {
         foreach ($excludes as $exclude) {
             $finder->exclude($exclude);
         }
     }
     return $finder;
 }
开发者ID:JSchwehn,项目名称:humbug,代码行数:25,代码来源:Humbug.php

示例15: getFinder

 /**
  *
  * @return Finder
  */
 protected function getFinder()
 {
     if (null === $this->finder) {
         $finder = new Finder();
         $settings = $this->getSettings();
         foreach ($settings->getSrc() as $source) {
             if (is_dir($source)) {
                 $finder->in($source);
             }
             if (is_file($source)) {
                 $finder->append(array($source));
             }
         }
         if (true === $settings->getFollowLinks()) {
             $finder->followLinks();
         }
         $finder->ignoreDotFiles($settings->getIgnoreDotFiles());
         $finder->name($settings->getFileSuffix());
         $finder->exclude($settings->getExclude());
         if (NULL !== $settings->getDate()) {
             $finder->date($settings->getDate());
         }
         $this->setFinder($finder);
     }
     return $this->finder;
 }
开发者ID:slavomirkuzma,项目名称:itc-bundle,代码行数:30,代码来源:Reflection.php


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