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


PHP Finder\Finder类代码示例

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


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

示例1: tearDown

 public function tearDown()
 {
     // Delete local files
     $finder = new Finder();
     $fs = new Filesystem();
     $fs->remove($finder->files()->in($this->tmpDir . "/download"));
     $fs->remove($finder->files()->in($this->tmpDir));
     $fs->remove($this->tmpDir . "/download");
     $fs->remove($this->tmpDir);
     // Delete file uploads
     $options = new ListFilesOptions();
     $options->setTags(["docker-bundle-test"]);
     $files = $this->client->listFiles($options);
     foreach ($files as $file) {
         $this->client->deleteFile($file["id"]);
     }
     if ($this->client->bucketExists("in.c-docker-test")) {
         // Delete tables
         foreach ($this->client->listTables("in.c-docker-test") as $table) {
             $this->client->dropTable($table["id"]);
         }
         // Delete bucket
         $this->client->dropBucket("in.c-docker-test");
     }
     if ($this->client->bucketExists("in.c-docker-test-redshift")) {
         // Delete tables
         foreach ($this->client->listTables("in.c-docker-test-redshift") as $table) {
             $this->client->dropTable($table["id"]);
         }
         // Delete bucket
         $this->client->dropBucket("in.c-docker-test-redshift");
     }
 }
开发者ID:keboola,项目名称:input-mapping,代码行数:33,代码来源:StorageApiReaderTest.php

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

示例3: compile

 /**
  * Compiles phar archive.
  *
  * @param string $version
  */
 public function compile($version)
 {
     if (file_exists($package = "behat-{$version}.phar")) {
         unlink($package);
     }
     // create phar
     $phar = new \Phar($package, 0, 'behat.phar');
     $phar->setSignatureAlgorithm(\Phar::SHA1);
     $phar->startBuffering();
     $finder = new Finder();
     $finder->files()->ignoreVCS(true)->name('*.php')->name('*.xsd')->name('*.xml')->name('LICENSE')->notName('PharCompiler.php')->notName('PearCompiler.php')->in($this->libPath . '/src')->in($this->libPath . '/vendor');
     foreach ($finder as $file) {
         // don't compile test suites
         if (!preg_match('/\\/tests\\/|\\/test\\//i', $file->getRealPath())) {
             $this->addFileToPhar($file, $phar);
         }
     }
     // license and autoloading
     $this->addFileToPhar(new \SplFileInfo($this->libPath . '/LICENSE'), $phar);
     $this->addFileToPhar(new \SplFileInfo($this->libPath . '/i18n.php'), $phar);
     // stub
     $phar->setStub($this->getStub($version));
     $phar->stopBuffering();
     unset($phar);
 }
开发者ID:saberyounis,项目名称:Sonata-Project,代码行数:30,代码来源:PharCompiler.php

示例4: compile

 /**
  * Compile new composer.phar
  * @param string $filename
  */
 public function compile($filename = 'codecept.phar')
 {
     if (file_exists($filename)) {
         unlink($filename);
     }
     $phar = new \Phar($filename, 0, 'codecept.phar');
     $phar->setSignatureAlgorithm(\Phar::SHA1);
     $phar->startBuffering();
     $finder = new Finder();
     $finder->files()->ignoreVCS(true)->name('*.php')->name('*.tpl.dist')->name('*.html.dist')->in($this->compileDir . '/src');
     foreach ($finder as $file) {
         $this->addFile($phar, $file);
     }
     $finder = new Finder();
     $finder->files()->ignoreVCS(true)->name('*.php')->name('*.js')->name('*.css')->name('*.png')->name('*.tpl.dist')->name('*.html.dist')->exclude('Tests')->exclude('tests')->exclude('benchmark')->exclude('demo')->in($this->compileDir . '/plugins/frameworks');
     foreach ($finder as $file) {
         $this->addFile($phar, $file);
     }
     $finder = new Finder();
     $finder->files()->ignoreVCS(true)->name('*.php')->name('*.css')->name('*.png')->name('*.js')->name('*.css')->name('*.png')->name('*.tpl.dist')->name('*.html.dist')->exclude('Tests')->exclude('tests')->exclude('benchmark')->exclude('demo')->in($this->compileDir . '/vendor');
     foreach ($finder as $file) {
         $this->addFile($phar, $file);
     }
     $this->addFile($phar, new \SplFileInfo($this->compileDir . '/autoload.php'));
     $this->setMainExecutable($phar);
     $this->setStub($phar);
     $phar->stopBuffering();
     unset($phar);
 }
开发者ID:lenninsanchez,项目名称:donadores,代码行数:33,代码来源:Compiler.php

示例5: warmup

 protected function warmup($warmupDir)
 {
     $this->getContainer()->get('filesystem')->remove($warmupDir);
     $parent = $this->getContainer()->get('kernel');
     $class = get_class($parent);
     $namespace = '';
     if (false !== ($pos = strrpos($class, '\\'))) {
         $namespace = substr($class, 0, $pos);
         $class = substr($class, $pos + 1);
     }
     $kernel = $this->getTempKernel($parent, $namespace, $class, $warmupDir);
     $kernel->boot();
     $warmer = $kernel->getContainer()->get('cache_warmer');
     $warmer->enableOptionalWarmers();
     $warmer->warmUp($warmupDir);
     // fix container files and classes
     $regex = '/' . preg_quote($this->getTempKernelSuffix(), '/') . '/';
     $finder = new Finder();
     foreach ($finder->files()->name(get_class($kernel->getContainer()) . '*')->in($warmupDir) as $file) {
         $content = file_get_contents($file);
         $content = preg_replace($regex, '', $content);
         // fix absolute paths to the cache directory
         $content = preg_replace('/' . preg_quote($warmupDir, '/') . '/', preg_replace('/_new$/', '', $warmupDir), $content);
         file_put_contents(preg_replace($regex, '', $file), $content);
         unlink($file);
     }
     // fix meta references to the Kernel
     foreach ($finder->files()->name('*.meta')->in($warmupDir) as $file) {
         $content = preg_replace('/C\\:\\d+\\:"' . preg_quote($class . $this->getTempKernelSuffix(), '"/') . '"/', sprintf('C:%s:"%s"', strlen($class), $class), file_get_contents($file));
         file_put_contents($file, $content);
     }
 }
开发者ID:usefulthink,项目名称:symfony,代码行数:32,代码来源:CacheClearCommand.php

示例6: findTestClasses

 /**
  * @return array (string $file => string $class)
  */
 static function findTestClasses($paths)
 {
     $testClasses = array();
     $finder = new Finder();
     foreach ($paths as $path) {
         if (is_dir($path)) {
             foreach ($finder->files()->in($paths)->name('*Test.php') as $file) {
                 $testClass = self::_findTestClasses((string) $file);
                 if (count($testClass) == 1) {
                     $testClasses[(string) $file] = array_shift($testClass);
                 } elseif (count($testClass) > 1) {
                     throw new \Exception("Too many classes in {$file}");
                 } else {
                     throw new \Exception("Too few classes in {$file}");
                 }
             }
         } elseif (is_file($path)) {
             $testClass = self::_findTestClasses($path);
             if (count($testClass) == 1) {
                 $testClasses[$path] = array_shift($testClass);
             } elseif (count($testClass) > 1) {
                 throw new \Exception("Too many classes in {$path}");
             } else {
                 throw new \Exception("Too few classes in {$path}");
             }
         }
     }
     return $testClasses;
 }
开发者ID:prashantgajare,项目名称:civicrm-core,代码行数:32,代码来源:PHPUnitScanner.php

示例7: execute

 /**
  * {@inheritDoc}
  */
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $destDir = $this->getDestDir();
     $finder = new Finder();
     $fs = new Filesystem();
     try {
         $fs->mkdir($destDir);
     } catch (IOException $e) {
         $output->writeln(sprintf('<error>Could not create directory %s.</error>', $destDir));
         return;
     }
     $srcDir = $this->getSrcDir();
     if (false === file_exists($srcDir)) {
         $output->writeln(sprintf('<error>Fonts directory "%s" does not exist. Did you install twbs/bootstrap? ' . 'If you used something other than Composer you need to manually change the path in ' . '"braincrafted_bootstrap.assets_dir". If you want to use Font Awesome you need to install the font and change the option "braincrafted_bootstrap.fontawesome_dir".</error>', $srcDir));
         return;
     }
     $finder->files()->in($srcDir);
     foreach ($finder as $file) {
         $dest = sprintf('%s/%s', $destDir, $file->getBaseName());
         try {
             $fs->copy($file, $dest);
         } catch (IOException $e) {
             $output->writeln(sprintf('<error>Could not copy %s</error>', $file->getBaseName()));
             return;
         }
     }
     $output->writeln(sprintf('Copied icon fonts to <comment>%s</comment>.', $destDir));
 }
开发者ID:mgdigital,项目名称:bootstrap-bundle,代码行数:31,代码来源:InstallCommand.php

示例8: compile

 /**
  * Compiles composer into a single phar file
  *
  * @throws \RuntimeException
  */
 public function compile()
 {
     $pharFile = 'refactor.phar';
     if (file_exists($pharFile)) {
         unlink($pharFile);
     }
     $process = new Process('git log --pretty="%H" -n1 HEAD', $this->directory);
     if ($process->run() != 0) {
         throw new \RuntimeException('Can\'t run git log. You must ensure to run compile from git repository clone and that git binary is available.');
     }
     $this->version = trim($process->getOutput());
     $process = new Process('git describe --tags HEAD');
     if ($process->run() == 0) {
         $this->version = trim($process->getOutput());
     }
     $phar = new \Phar($pharFile, 0, 'refactor.phar');
     $phar->setSignatureAlgorithm(\Phar::SHA1);
     $phar->startBuffering();
     $finder = new Finder();
     $finder->files()->ignoreVCS(true)->name('*.php')->notName('Compiler.php')->in($this->directory . '/src/main');
     foreach ($finder as $file) {
         $this->addFile($phar, $file);
     }
     $finder = new Finder();
     $finder->files()->ignoreVCS(true)->name('*.php')->exclude('test')->exclude('features')->in($this->directory . '/vendor/');
     foreach ($finder as $file) {
         $this->addFile($phar, $file);
     }
     $this->addRefactorBin($phar);
     // Stubs
     $phar->setStub($this->getStub());
     $phar->stopBuffering();
     unset($phar);
 }
开发者ID:roozbehmatloobi,项目名称:php-refactoring-browser,代码行数:39,代码来源:Compiler.php

示例9: collectBundles

 protected function collectBundles()
 {
     $finder = new Finder();
     $bundles = array();
     $finder->files()->followLinks()->in(array($this->getRootDir() . '/../src', $this->getRootDir() . '/../vendor'))->name('bundles.yml');
     foreach ($finder as $file) {
         $import = Yaml::parse($file->getRealpath());
         foreach ($import['bundles'] as $bundle) {
             $kernel = false;
             $priority = 0;
             if (is_array($bundle)) {
                 $class = $bundle['name'];
                 $kernel = isset($bundle['kernel']) && true == $bundle['kernel'];
                 $priority = isset($bundle['priority']) ? (int) $bundle['priority'] : 0;
             } else {
                 $class = $bundle;
             }
             if (!isset($bundles[$class])) {
                 $bundles[$class] = array('name' => $class, 'kernel' => $kernel, 'priority' => $priority);
             }
         }
     }
     uasort($bundles, array($this, 'compareBundles'));
     return $bundles;
 }
开发者ID:ashutosh-srijan,项目名称:findit_akeneo,代码行数:25,代码来源:OroKernel.php

示例10: executeTags

 protected function executeTags(InputInterface $input, OutputInterface $output)
 {
     $this->tagsRepo = $this->dm->getRepository("PumukitSchemaBundle:Tag");
     $finder = new Finder();
     $finder->files()->in(__DIR__ . '/' . $this->tagsPath);
     $file = $input->getArgument('file');
     if (0 == strcmp($file, "") && !$finder) {
         $output->writeln("<error>Tags: There's no data to initialize</error>");
         return -1;
     }
     $publishingDecisionTag = $this->tagsRepo->findOneByCod("PUBDECISIONS");
     if (null == $publishingDecisionTag) {
         throw new \Exception("Trying to add children tags to the not created Publishing Decision Tag. Please init pumukit tags");
     }
     $rootTag = $this->tagsRepo->findOneByCod("ROOT");
     if (null == $rootTag) {
         throw new \Exception("Trying to add children tags to the not created ROOT Tag. Please init pumukit tags");
     }
     foreach ($finder as $tagFile) {
         if (0 < strpos(pathinfo($tagFile, PATHINFO_EXTENSION), '~')) {
             continue;
         }
         $parentTag = $this->getParentTag($tagFile, $rootTag, $publishingDecisionTag);
         $this->createFromFile($tagFile, $parentTag, $output);
     }
     if ($file) {
         $parentTag = $this->getParentTag($tagFile, $rootTag, $publishingDecisionTag);
         $this->createFromFile($file, $parentTag, $output);
     }
     return 0;
 }
开发者ID:bmartinezteltek,项目名称:PuMuKIT2,代码行数:31,代码来源:WebTVInitTagsCommand.php

示例11: getThemeFiles

 protected function getThemeFiles($code)
 {
     $files = array();
     $DS = DIRECTORY_SEPARATOR;
     $admin = str_replace(DIR_ROOT, '', DIR_ADMIN);
     $catalog = str_replace(DIR_ROOT, '', DIR_CATALOG);
     $image = str_replace(DIR_ROOT, '', DIR_IMAGE);
     // Theme files
     $theme_dir = $catalog . 'view' . $DS . 'theme' . $DS . $code;
     $finder = new SFinder();
     $finder->files()->in(DIR_ROOT . $theme_dir);
     foreach ($finder as $file) {
         $files[] = $theme_dir . $DS . $file->getRelativePathname();
     }
     // Thumbnail
     $thumbnail = 'templates' . $DS . $code . '.png';
     if (file_exists(DIR_IMAGE . $thumbnail)) {
         $files[] = $image . $thumbnail;
     }
     // Language
     $language = 'language' . $DS . 'en-GB' . $DS . 'theme' . $DS . $code . '.php';
     if (file_exists(DIR_ADMIN . $language)) {
         $files[] = $admin . $language;
     }
     return $files;
 }
开发者ID:LinuxJedi,项目名称:arastta,代码行数:26,代码来源:theme.php

示例12: process

 public function process(ContainerBuilder $container)
 {
     $dirs = array();
     foreach ($container->getParameter('kernel.bundles') as $bundle) {
         $reflection = new \ReflectionClass($bundle);
         if (is_dir($dir = dirname($reflection->getFilename()) . '/Resources/config/validation')) {
             $dirs[] = $dir;
         }
     }
     if (is_dir($dir = $container->getParameter('kernel.root_dir') . '/Resources/config/validation')) {
         $dirs[] = $dir;
     }
     $newFiles = array();
     if ($dirs) {
         $finder = new Finder();
         $finder->files()->name('*.xml')->in($dirs);
         foreach ($finder as $file) {
             $newFiles[] = $file->getPathName();
         }
     }
     $validatorBuilder = $container->getDefinition('validator.builder');
     if (count($newFiles) > 0) {
         $validatorBuilder->addMethodCall('addXmlMappings', array($newFiles));
     }
 }
开发者ID:phecho,项目名称:gitonomy,代码行数:25,代码来源:AddValidationFilesPass.php

示例13: createKernel

 /**
  * Creates a Kernel.
  *
  * If you run tests with the PHPUnit CLI tool, everything will work as expected.
  * If not, override this method in your test classes.
  *
  * Available options:
  *
  *  * environment
  *  * debug
  *
  * @param array $options An array of options
  *
  * @return HttpKernelInterface A HttpKernelInterface instance
  */
 protected function createKernel(array $options = array())
 {
     // black magic below, you have been warned!
     $dir = getcwd();
     if (!isset($_SERVER['argv']) || false === strpos($_SERVER['argv'][0], 'phpunit')) {
         throw new \RuntimeException('You must override the WebTestCase::createKernel() method.');
     }
     // find the --configuration flag from PHPUnit
     $cli = implode(' ', $_SERVER['argv']);
     if (preg_match('/\\-\\-configuration[= ]+([^ ]+)/', $cli, $matches)) {
         $dir = $dir . '/' . $matches[1];
     } elseif (preg_match('/\\-c +([^ ]+)/', $cli, $matches)) {
         $dir = $dir . '/' . $matches[1];
     } else {
         throw new \RuntimeException('Unable to guess the Kernel directory.');
     }
     if (!is_dir($dir)) {
         $dir = dirname($dir);
     }
     $finder = new Finder();
     $finder->name('*Kernel.php')->in($dir);
     if (!count($finder)) {
         throw new \RuntimeException('You must override the WebTestCase::createKernel() method.');
     }
     $file = current(iterator_to_array($finder));
     $class = $file->getBasename('.php');
     unset($finder);
     require_once $file;
     return new $class(isset($options['environment']) ? $options['environment'] : 'test', isset($options['debug']) ? $debug : true);
 }
开发者ID:skoop,项目名称:symfony-sandbox,代码行数:45,代码来源:WebTestCase.php

示例14: execute

 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $argument = $input->getArgument('argument');
     if ($input->getOption('option')) {
         // ...
     }
     //extract all files from a folder
     $path = __DIR__ . "/../../../var/data/";
     $em = $this->getContainer()->get('doctrine')->getManager();
     $finder = new Finder();
     $finder->files()->in($path);
     $extractor = $this->getContainer()->get('excel.extractor.catalunyacaixa');
     $entryExcels = $extractor->extractFromPath($finder);
     $entryExcelManager = $this->getContainer()->get('entry.excel.manager');
     $totalUpdated = 0;
     foreach ($entryExcels as $entryExcel) {
         if (!$entryExcelManager->existsEntryExcel($entryExcel)) {
             $totalUpdated++;
             $entry = $entryExcelManager->createEntryEntity($entryExcel);
             $em->persist($entry);
         }
     }
     $em->flush();
     $output->writeln('Created: ' . $totalUpdated);
 }
开发者ID:joanteixi,项目名称:accountUnderControl,代码行数:25,代码来源:DataImportExcelCommand.php

示例15: locate

 /**
  * {@inheritdoc}
  */
 public function locate($name, $currentPath = null, $first = true)
 {
     if (empty($name)) {
         throw new \InvalidArgumentException('An empty file name is not valid to be located.');
     }
     if ($this->isAbsolutePath($name)) {
         if (!file_exists($name)) {
             throw new \InvalidArgumentException(sprintf('The file "%s" does not exist.', $name));
         }
         return $name;
     }
     $directories = $this->paths;
     if (null !== $currentPath) {
         $directories[] = $currentPath;
         $directories = array_values(array_unique($directories));
     }
     $filepaths = [];
     $finder = new Finder();
     $finder->files()->name($name)->ignoreUnreadableDirs()->in($directories);
     /** @var SplFileInfo $file */
     if ($first && null !== ($file = $finder->getIterator()->current())) {
         return $file->getPathname();
     }
     foreach ($finder as $file) {
         $filepaths[] = $file->getPathname();
     }
     if (!$filepaths) {
         throw new \InvalidArgumentException(sprintf('The file "%s" does not exist (in: %s).', $name, implode(', ', $directories)));
     }
     return array_values(array_unique($filepaths));
 }
开发者ID:liverbool,项目名称:dos-theme-bundle,代码行数:34,代码来源:RecursiveFileLocator.php


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