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


PHP Finder::name方法代码示例

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


在下文中一共展示了Finder::name方法的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: 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

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

示例4: execute

 /**
  * Executes the current command.
  *
  * @param InputInterface  $input  An InputInterface instance
  * @param OutputInterface $output An OutputInterface instance
  *
  * @return null|integer null or 0 if everything went fine, or an error code
  */
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $paths = $input->getArgument('paths');
     $finder = new Finder();
     $finder->files();
     $finder->name('*.php');
     foreach ($paths as $path) {
         $finder->in($path);
     }
     try {
         $files = $finder->getIterator();
     } catch (\Exception $ex) {
         return 1;
     }
     if (empty($files)) {
         $output->writeln('No files to analyze');
         return 1;
     }
     $analyzer = new Analyzer();
     $result = $analyzer->run($files);
     $output->writeln('<html><body><pre>');
     $output->writeln(print_r($result, true));
     $output->writeln('</pre></body></html>');
     return 0;
 }
开发者ID:hacfi,项目名称:php-file-analyzer,代码行数:33,代码来源:Command.php

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

示例6: setUp

 /**
  * Prepares test environment.
  */
 public function setUp()
 {
     $finder = new Finder();
     $finder->files()->in(__DIR__ . '/config/');
     $finder->name('*.yml');
     $this->dummyParser = $this->getMock('Symfony\\Component\\Yaml\\Parser');
     $this->dummyDumper = $this->getMock('Symfony\\Component\\Yaml\\Dumper');
     $this->dummyFilesystem = $this->getMock('Symfony\\Component\\Filesystem\\Filesystem');
     $dummyDispatcher = $this->getMock('Symfony\\Component\\EventDispatcher\\EventDispatcherInterface');
     $dummyDispatcher->expects($this->once())->method('dispatch')->willReturnCallback(function ($name, $event) {
         /** @var GroupOptionTypeEvent $event */
         $optionTypes = ['acp' => ['twomartens.core' => ['access' => new BooleanOptionType()]]];
         $event->addOptions($optionTypes);
     });
     $this->yamlData = [];
     $this->optionData = [];
     foreach ($finder as $file) {
         /** @var SplFileInfo $file */
         $basename = $file->getBasename('.yml');
         $this->yamlData[$basename] = Yaml::parse($file->getContents());
         $this->optionData[$basename] = ConfigUtil::convertToOptions($this->yamlData[$basename]);
     }
     $this->dummyParser->expects($this->any())->method('parse')->willReturnCallback(function ($content) {
         return Yaml::parse($content);
     });
     /** @var \Symfony\Component\EventDispatcher\EventDispatcherInterface $dummyDispatcher */
     $this->groupService = new GroupService($finder, $this->dummyParser, $this->dummyDumper, $this->dummyFilesystem, $dummyDispatcher);
 }
开发者ID:2martens,项目名称:web-platform,代码行数:31,代码来源:GroupServiceTest.php

示例7: 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());
 }
开发者ID:navassouza,项目名称:symfony,代码行数:16,代码来源:FinderTest.php

示例8: execute

 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $name = $input->getArgument('name');
     if (is_numeric($name)) {
         $name = (int) $name;
     }
     $appliedMigrations = $this->getAppliedMigration('DESC');
     $i = 0;
     foreach ($appliedMigrations as $appliedMigration => $v) {
         $finder = new Finder();
         /** @var SplFileInfo $file */
         $file = array_values(iterator_to_array($finder->name($appliedMigration . '.php')->in($this->config['migration_path'])))[0];
         $appliedMigration = $this->getAppliedMigration();
         if (!isset($appliedMigration[$file->getBasename('.php')])) {
             continue;
         }
         if (!($migration = $this->isMigration($file))) {
             continue;
         }
         ++$i;
         $className = $file->getBasename('.php');
         $output->writeln('Запущен откат миграции: ' . $className);
         $this->runMigration($className, $migration->down(), 'down');
         $this->unsetAppliedMigration($className);
         $output->writeln('Отменена миграция: ' . $className);
         if (!is_null($name) && ($className == $name || $name === $i)) {
             break;
         }
     }
 }
开发者ID:georgynet,项目名称:migration,代码行数:30,代码来源:RevertMigrationCommand.php

示例9: updateModules

 public function updateModules()
 {
     $finder = new Finder();
     $finder->name('module.xml')->in($this->baseModuleDir . '/*/Config');
     $descriptorValidator = new ModuleDescriptorValidator();
     foreach ($finder as $file) {
         $content = $descriptorValidator->getDescriptor($file->getRealPath());
         $reflected = new \ReflectionClass((string) $content->fullnamespace);
         $code = basename(dirname($reflected->getFileName()));
         $con = Propel::getWriteConnection(ModuleTableMap::DATABASE_NAME);
         $con->beginTransaction();
         try {
             $module = ModuleQuery::create()->filterByCode($code)->findOne();
             if (null === $module) {
                 $module = new Module();
                 $module->setCode($code)->setFullNamespace((string) $content->fullnamespace)->setType($this->getModuleType($reflected))->setActivate(0)->save($con);
             }
             $this->saveDescription($module, $content, $con);
             $con->commit();
         } catch (PropelException $e) {
             $con->rollBack();
             throw $e;
         }
     }
 }
开发者ID:fachriza,项目名称:thelia,代码行数:25,代码来源:ModuleManagement.php

示例10: load

 /**
  * Load, instantiate and sort all fixture files found
  * within the given paths.
  *
  * @param array $paths
  *
  * @return DocumentFixtureInterface[]
  */
 public function load(array $paths)
 {
     $finder = new Finder();
     $finder->in($paths);
     $finder->name('*Fixture.php');
     foreach ($finder as $file) {
         $declaredClasses = get_declared_classes();
         require_once $file;
         $declaredClassesDiff = array_diff(get_declared_classes(), $declaredClasses);
         $fixtureClass = array_pop($declaredClassesDiff);
         if (!$fixtureClass) {
             throw new \InvalidArgumentException(sprintf('Could not determine class from included file "%s". Class detection will only work once per request.', $file));
         }
         $refl = new \ReflectionClass($fixtureClass);
         if ($refl->isAbstract()) {
             continue;
         }
         if (false === $refl->isSubclassOf(DocumentFixtureInterface::class)) {
             continue;
         }
         $fixture = new $fixtureClass();
         if ($fixture instanceof ContainerAwareInterface) {
             $fixture->setContainer($this->container);
         }
         $fixtures[] = $fixture;
     }
     usort($fixtures, function (DocumentFixtureInterface $fixture1, DocumentFixtureInterface $fixture2) {
         return $fixture1->getOrder() > $fixture2->getOrder();
     });
     return $fixtures;
 }
开发者ID:Silwereth,项目名称:sulu,代码行数:39,代码来源:DocumentFixtureLoader.php

示例11: execute

 /**
  * @see Command
  *
  * @throws \InvalidArgumentException When the target directory does not exist
  */
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $this->writeSection($output, '[Propel] You are running the command: propel:build-sql');
     if ($input->getOption('verbose')) {
         $this->additionalPhingArgs[] = 'verbose';
     }
     $finder = new Finder();
     $filesystem = new Filesystem();
     $sqlDir = $this->getApplication()->getKernel()->getRootDir() . DIRECTORY_SEPARATOR . 'propel' . DIRECTORY_SEPARATOR . 'sql';
     $filesystem->remove($sqlDir);
     $filesystem->mkdir($sqlDir);
     // Execute the task
     $ret = $this->callPhing('build-sql', array('propel.sql.dir' => $sqlDir));
     if (true === $ret) {
         $files = $finder->name('*')->in($sqlDir);
         $nbFiles = 0;
         foreach ($files as $file) {
             $this->writeNewFile($output, (string) $file);
             if ('sql' === pathinfo($file->getFilename(), PATHINFO_EXTENSION)) {
                 $nbFiles++;
             }
         }
         $this->writeSection($output, sprintf('<comment>%d</comment> <info>SQL file%s ha%s been generated.</info>', $nbFiles, $nbFiles > 1 ? 's' : '', $nbFiles > 1 ? 've' : 's'), 'bg=black');
     } else {
         $this->writeSection($output, array('[Propel] Error', '', 'An error has occured during the "build-sql" task process. To get more details, run the command with the "--verbose" option.'), 'fg=white;bg=red');
     }
 }
开发者ID:hhamon,项目名称:PropelBundle,代码行数:32,代码来源:BuildSqlCommand.php

示例12: execute

 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $name = $input->getArgument('name');
     if (is_numeric($name)) {
         $name = (int) $name;
     }
     $finder = new Finder();
     $finder->name(BaseMigrationCommand::PREFIX_MIGRATION_NAME . '*' . '.php')->in($this->config['migration_path'])->sortByName();
     $i = 0;
     /** @var SplFileInfo $file */
     foreach ($finder as $file) {
         $appliedMigration = $this->getAppliedMigration();
         if (isset($appliedMigration[$file->getBasename('.php')])) {
             continue;
         }
         if (!($migration = $this->isMigration($file))) {
             continue;
         }
         ++$i;
         $className = $file->getBasename('.php');
         $output->writeln('Запущена миграция: ' . $className);
         $this->runMigration($className, $migration->up(), 'up');
         $this->setAppliedMigration($className);
         $output->writeln('Применена миграция: ' . $className);
         if (!is_null($name) && ($className == $name || $name === $i)) {
             break;
         }
     }
 }
开发者ID:georgynet,项目名称:migration,代码行数:29,代码来源:ApplyMigrationCommand.php

示例13: getFiles

 /**
  * Gets the file(s) to process from the given path
  *
  * @param string $path The path to the source file(s)
  *
  * @return SplFileInfo[]
  */
 private function getFiles($path)
 {
     if (is_file($path)) {
         return [new SplFileInfo($path, '', '')];
     }
     return $this->finder->name('*.php')->in(realpath($path));
 }
开发者ID:jameshalsall,项目名称:licenser,代码行数:14,代码来源:Licenser.php

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

示例15: fire

 /**
  * Execute the console command.
  *
  * @return void
  */
 public function fire()
 {
     $vendorDir = realpath($this->argument('dir'));
     $this->info("Cleaning dir: {$vendorDir}");
     $rules = Config::get('laravel-vendor-cleanup::rules');
     $filesystem = new Filesystem();
     foreach ($rules as $packageDir => $rule) {
         if (!file_exists($vendorDir . '/' . $packageDir)) {
             continue;
         }
         $patterns = explode(' ', $rule);
         foreach ($patterns as $pattern) {
             try {
                 $finder = new Finder();
                 $finder->name($pattern)->in($vendorDir . '/' . $packageDir);
                 // we can't directly iterate over $finder if it lists dirs we're deleting
                 $files = iterator_to_array($finder);
                 /** @var \SplFileInfo $file */
                 foreach ($files as $file) {
                     if ($file->isDir()) {
                         $filesystem->deleteDirectory($file);
                     } elseif ($file->isFile()) {
                         $filesystem->delete($file);
                     }
                 }
             } catch (\Exception $e) {
                 $this->error("Could not parse {$packageDir} ({$pattern}): " . $e->getMessage());
             }
         }
     }
 }
开发者ID:zzzace2000,项目名称:laravel-vendor-cleanup,代码行数:36,代码来源:VendorCleanupCommand.php


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