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


PHP Finder::in方法代码示例

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


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

示例1: findBenchmarks

 /**
  * Build the BenchmarkMetadata collection.
  *
  * @param string $path
  * @param array $subjectFilter
  * @param array $groupFilter
  */
 public function findBenchmarks($path, array $subjectFilter = [], array $groupFilter = [])
 {
     $finder = new Finder();
     $path = PhpBench::normalizePath($path);
     if (!file_exists($path)) {
         throw new \InvalidArgumentException(sprintf('File or directory "%s" does not exist (cwd: %s)', $path, getcwd()));
     }
     if (is_dir($path)) {
         $finder->in($path)->name('*.php');
     } else {
         // the path is already a file, just restrict the finder to that.
         $finder->in(dirname($path))->depth(0)->name(basename($path));
     }
     $benchmarks = [];
     foreach ($finder as $file) {
         if (!is_file($file)) {
             continue;
         }
         $benchmark = $this->factory->getMetadataForFile($file->getPathname());
         if (null === $benchmark) {
             continue;
         }
         if ($groupFilter) {
             $benchmark->filterSubjectGroups($groupFilter);
         }
         if ($subjectFilter) {
             $benchmark->filterSubjectNames($subjectFilter);
         }
         if (false === $benchmark->hasSubjects()) {
             continue;
         }
         $benchmarks[] = $benchmark;
     }
     return $benchmarks;
 }
开发者ID:dantleech,项目名称:phpbench,代码行数:42,代码来源:BenchmarkFinder.php

示例2: isDrupal

 /**
  * Detect if there are any Drupal applications in a folder.
  *
  * @param string $directory
  * @param mixed  $depth
  *
  * @return bool
  */
 public static function isDrupal($directory, $depth = '< 2')
 {
     if (!is_dir($directory)) {
         return false;
     }
     $finder = new Finder();
     // Look for at least one Drush make file.
     $finder->in($directory)->files()->depth($depth)->name('project.make*')->name('drupal-org.make*');
     foreach ($finder as $file) {
         return true;
     }
     // Check whether there is an index.php file whose first few lines
     // contain the word "Drupal".
     $finder->in($directory)->files()->depth($depth)->name('index.php');
     foreach ($finder as $file) {
         $f = fopen($file, 'r');
         $beginning = fread($f, 3178);
         fclose($f);
         if (strpos($beginning, 'Drupal') !== false) {
             return true;
         }
     }
     // Check whether there is a composer.json file requiring Drupal core.
     $finder->in($directory)->files()->depth($depth)->name('composer.json');
     foreach ($finder as $file) {
         $composerJson = json_decode(file_get_contents($file), true);
         if (isset($composerJson['require']['drupal/core']) || isset($composerJson['require']['drupal/phing-drush-task'])) {
             return true;
         }
     }
     return false;
 }
开发者ID:ecolinet,项目名称:platformsh-cli,代码行数:40,代码来源:Drupal.php

示例3: getFinderData

 public function getFinderData($searchElement)
 {
     ini_set('memory_limit', '-1');
     $searchResult = explode(' ', $searchElement);
     $finalDataArr = array();
     // define the path in which file is resides.
     $dir = $this->get('kernel')->getRootDir() . '/../web/uploads/files/';
     // if csv dir does not exist create new one
     if (!is_dir($dir)) {
         mkdir($dir);
     }
     // call the finder class.
     $finder = new Finder();
     $finder->in($dir)->ignoreDotFiles(false);
     $finder->in($dir);
     $finder->in($dir)->files()->name('*.*');
     foreach ($searchResult as $value) {
         $finder->in($dir)->files()->contains($value);
     }
     foreach ($finder as $file) {
         $finalDataArr[] = $file->getRelativePathname();
     }
     $finalDataArr = array_unique($finalDataArr);
     return $finalDataArr;
 }
开发者ID:montu0074i,项目名称:orotest,代码行数:25,代码来源:FinderServiceController.php

示例4: execute

 /**
  * call execute on found commands
  *
  * @param InputInterface  $input  user input
  * @param OutputInterface $output command output
  *
  * @return void
  */
 public function execute(InputInterface $input, OutputInterface $output)
 {
     $this->finder->in(strpos(getcwd(), 'vendor/') === false ? getcwd() : getcwd() . '/../../../../')->path('Resources/config')->name('/migrations.(xml|yml)/')->files();
     foreach ($this->finder as $file) {
         if (!$file->isFile()) {
             continue;
         }
         $output->writeln('Found ' . $file->getRelativePathname());
         $command = $this->getApplication()->find('mongodb:migrations:migrate');
         $helperSet = $command->getHelperSet();
         $helperSet->set($this->documentManager, 'dm');
         $command->setHelperSet($helperSet);
         $configuration = $this->getConfiguration($file->getPathname(), $output);
         self::injectContainerToMigrations($this->container, $configuration->getMigrations());
         $command->setMigrationConfiguration($configuration);
         $arguments = $input->getArguments();
         $arguments['command'] = 'mongodb:migrations:migrate';
         $arguments['--configuration'] = $file->getPathname();
         $migrateInput = new ArrayInput($arguments);
         $returnCode = $command->run($migrateInput, $output);
         if ($returnCode !== 0) {
             $output->writeln('<error>Calling mongodb:migrations:migrate failed for ' . $file->getRelativePathname() . '</error>');
             return $returnCode;
         }
     }
 }
开发者ID:alebon,项目名称:graviton,代码行数:34,代码来源:MongodbMigrateCommand.php

示例5: buildCollection

 /**
  * Build the BenchmarkMetadata collection.
  *
  * @param string $path
  * @param array $subjectFilter
  * @param array $groupFilter
  */
 public function buildCollection($path, array $filters = array(), array $groupFilter = array())
 {
     if (!file_exists($path)) {
         throw new \InvalidArgumentException(sprintf('File or directory "%s" does not exist (cwd: %s)', $path, getcwd()));
     }
     if (is_dir($path)) {
         $this->finder->in($path)->name('*Bench.php');
     } else {
         // the path is already a file, just restrict the finder to that.
         $this->finder->in(dirname($path))->depth(0)->name(basename($path));
     }
     $benchmarks = array();
     foreach ($this->finder as $file) {
         if (!is_file($file)) {
             continue;
         }
         $benchmarkMetadata = $this->factory->getMetadataForFile($file->getPathname());
         if (null === $benchmarkMetadata) {
             continue;
         }
         if ($groupFilter) {
             $benchmarkMetadata->filterSubjectGroups($groupFilter);
         }
         if ($filters) {
             $benchmarkMetadata->filterSubjectNames($filters);
         }
         if (false === $benchmarkMetadata->hasSubjects()) {
             continue;
         }
         $benchmarks[] = $benchmarkMetadata;
     }
     return new Collection($benchmarks);
 }
开发者ID:stof,项目名称:phpbench,代码行数:40,代码来源:CollectionBuilder.php

示例6: getLayouts

 /**
  * @return array
  * @throws \InvalidArgumentException
  */
 private function getLayouts()
 {
     $layouts = new \ArrayIterator(array());
     if (is_dir($this->baseDir . '/layouts')) {
         $layouts = $this->finder->in($this->baseDir . '/layouts/')->files()->name('authors.*.twig');
     }
     $layouts = iterator_to_array($layouts);
     if (empty($layouts)) {
         throw new \InvalidArgumentException('Could not find layout for author pages.');
     }
     return $layouts;
 }
开发者ID:seiffert,项目名称:carew-authors,代码行数:16,代码来源:AuthorIndexGenerator.php

示例7: fire

 /**
  * fire.
  */
 public function fire()
 {
     // set_time_limit(30);
     $path = $this->argument('path');
     $name = $this->option('name');
     $type = $this->option('type');
     $maxDepth = $this->option('maxdepth');
     $delete = $this->option('delete');
     $root = $this->getLaravel()->basePath();
     $path = realpath($root . '/' . $path);
     $this->finder->in($path);
     if ($name !== null) {
         $this->finder->name($name);
     }
     switch ($type) {
         case 'd':
             $this->finder->directories();
             break;
         case 'f':
             $this->finder->files();
             break;
     }
     if ($maxDepth !== null) {
         if ($maxDepth == '0') {
             $this->line($path);
             return;
         }
         $this->finder->depth('<' . $maxDepth);
     }
     foreach ($this->finder as $file) {
         $realPath = $file->getRealpath();
         if ($delete === 'true' && $filesystem->exists($realPath) === true) {
             try {
                 if ($filesystem->isDirectory($realPath) === true) {
                     $deleted = $filesystem->deleteDirectory($realPath, true);
                 } else {
                     $deleted = $filesystem->delete($realPath);
                 }
             } catch (Exception $e) {
             }
             if ($deleted === true) {
                 $this->info('removed ' . $realPath);
             } else {
                 $this->error('removed ' . $realPath . ' fail');
             }
         } else {
             $this->line($file->getRealpath());
         }
     }
 }
开发者ID:recca0120,项目名称:laravel-terminal,代码行数:53,代码来源:Find.php

示例8: scan

 /**
  * Find the specified theme by searching a 'theme.json' file as identifier.
  *
  * @param string $path
  * @param string $filename
  *
  * @return $this
  */
 public function scan()
 {
     if ($this->scanned == true) {
         return $this;
     }
     if (is_dir($path = $this->getPath())) {
         $found = $this->finder->in($path)->files()->name(self::FILENAME)->depth('<= 3')->followLinks();
         foreach ($found as $file) {
             $this->themes[] = new Theme($this->getInfo($file));
         }
     }
     $this->scanned = true;
     return $this;
 }
开发者ID:drickferreira,项目名称:rastreador,代码行数:22,代码来源:Finder.php

示例9: loadMetadata

 protected function loadMetadata()
 {
     $bundles = $this->kernel->getBundles();
     $finder = new Finder();
     foreach ($bundles as $bundle) {
         $finder->in($bundle->getPath());
     }
     $finder->in($this->kernel->getRootDir());
     $finder->name("*.fs.yml");
     foreach ($finder as $file) {
         $fsData = $this->frontSynchroniserManager->getMetadataFromPath($file->getPathname());
         $metadata = $this->buildMetadata($fsData, $file);
         $this->storeMetadata($metadata);
     }
 }
开发者ID:jean-pasqualini,项目名称:front-synchroniser,代码行数:15,代码来源:FrontSynchroniserFinder.php

示例10: getProject

 /**
  * Fetch drupal project from source code
  *
  * @return Sauron\Core\Drupal\Project\Entity\Project a Drupal project
  */
 public function getProject()
 {
     $project = new Project();
     if (file_exists($this->drupalRootPath . '/core')) {
         //looks like drupal >= 8 core
         $moduleSystemPath = $this->drupalRootPath . '/core/modules/system';
     } else {
         $moduleSystemPath = $this->drupalRootPath . '/modules/system';
     }
     //get core version
     $finder = new Finder();
     $systemInfoFile = $finder->in($moduleSystemPath)->files()->name('system.info*');
     $coreVersion = null;
     foreach ($systemInfoFile as $file) {
         $coreVersion = $this->getVersion($file->getRealpath());
     }
     //get module version
     if ($coreVersion !== null) {
         $project->drupalVersion = $coreVersion;
         $project->coreVersion = substr($coreVersion, 0, 1) . '.x';
         foreach ($this->extensionPaths as $contribPath) {
             $finder = new Finder();
             $moduleFiles = $finder->in($this->drupalRootPath . '/' . $contribPath)->files()->name('/\\.info(\\.yml)*$/')->depth('== 1');
             foreach ($moduleFiles as $file) {
                 $module = new Module();
                 $module->machineName = $file->getBasename('.info');
                 $module->version = $this->getVersion($file->getRealpath());
                 $project->modules[] = $module;
             }
         }
     }
     return $project;
 }
开发者ID:drupal-sauron,项目名称:monitoring,代码行数:38,代码来源:Filesystem.php

示例11: execute

 /**
  * {@inheritdoc}
  */
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $path = $input->getArgument('path');
     if (!file_exists($path)) {
         throw new FileNotFoundException($path);
     }
     /** @var EntityManager $em */
     $em = $this->app['orm.em'];
     // Disable SQL Logger
     $em->getConnection()->getConfiguration()->setSQLLogger(null);
     if (!$input->getOption('append')) {
         $output->writeln('Purging database');
         $em->getConnection()->executeUpdate("DELETE FROM address");
     }
     if (is_dir($path)) {
         $finder = new Finder();
         $finder->in($path)->name('/\\.csv/i');
         $output->writeln('Loading CSV from ' . $path . ' (' . $finder->count() . ' files)');
         /** @var SplFileInfo $file */
         foreach ($finder as $file) {
             $this->loadFile($output, $file->getPathname());
         }
     } else {
         $this->loadFile($output, $path);
     }
     return 0;
 }
开发者ID:kzykhys,项目名称:portable-zipcode-api,代码行数:30,代码来源:ImportCommand.php

示例12: 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

示例13: testFinderBuilderClear

 public function testFinderBuilderClear()
 {
     $finder = FinderBuilder::create()->in(sys_get_temp_dir())->name('*.php')->notName('*.js')->path('/plugin')->notPath('/vendor')->exclude('/js')->clearPath()->clearNotPath()->clearExclude()->build();
     $expectedFinder = new Finder();
     $expectedFinder->in(sys_get_temp_dir())->name('*.php')->notName('*.js');
     self::assertEquals($expectedFinder, $finder);
 }
开发者ID:rafrsr,项目名称:licenser,代码行数:7,代码来源:FinderBuilderTest.php

示例14: boot

 public function boot()
 {
     if (true === $this->booted) {
         return;
     }
     $this->booted = true;
     $moduleConfigCacheFile = $this->getParameter('kernel.root_dir') . '/cache/' . $this->environment . '/modules_config.php';
     if (file_exists($moduleConfigCacheFile)) {
         $this->_moduleConfig = (include $moduleConfigCacheFile);
     } else {
         $finder = new Finder();
         $finder->directories()->depth('== 0');
         foreach ($this->_moduleDirectories as $dir) {
             if (glob($dir . '/*/Service', GLOB_ONLYDIR)) {
                 $finder->in($dir . '/*/Service');
             }
         }
         foreach ($finder as $dir) {
             $filepath = $dir->getRealPath() . '/module_config.php';
             if (file_exists($filepath)) {
                 $this->_moduleConfig = array_merge_recursive($this->_moduleConfig, include $filepath);
             }
         }
         if (!$this->debug) {
             $cache = "<?php \nreturn " . var_export($this->_moduleConfig, true) . ';';
             file_put_contents($moduleConfigCacheFile, $cache);
         }
     }
     $subscribers = empty($this->_moduleConfig['event_subscriber']) ? array() : $this->_moduleConfig['event_subscriber'];
     foreach ($subscribers as $subscriber) {
         $this->dispatcher()->addSubscriber(new $subscriber());
     }
 }
开发者ID:Loyalsoldier,项目名称:8000wei-v2,代码行数:33,代码来源:ServiceKernel.php

示例15: find

 /**
  *
  * @param SpritePackageInterface[]|Package[] $packages
  * @return SpriteImage
  */
 public function find($packages)
 {
     // Get icons
     $sprites = [];
     foreach ($packages as $package) {
         foreach ($package->getPaths() as $path) {
             $finder = new Finder();
             $finder->sortByChangedTime();
             $finder->sortByAccessedTime();
             $finder->name('/\\.(png|jpg|gif)$/');
             foreach ($finder->in($path) as $fileInfo) {
                 $sprite = new SpriteImage($path, $fileInfo);
                 if (!array_key_exists($sprite->hash, $sprites)) {
                     // Add new sprite to set if hash does not exists
                     $sprites[$sprite->hash] = $sprite;
                 }
                 // Sprite with selected hash exists, just add package
                 if (!in_array($package, $sprites[$sprite->hash]->packages)) {
                     $sprites[$sprite->hash]->packages[] = $package;
                 }
             }
         }
     }
     return $sprites;
 }
开发者ID:maslosoft,项目名称:sprite,代码行数:30,代码来源:ImageFinder.php


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