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


PHP Finder::append方法代码示例

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


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

示例1: __construct

 /**
  * Track a set of paths
  *
  * @param array $paths the list of directories or files to track / follow
  */
 public function __construct(array $paths)
 {
     //Filter out the files, the Finder class can not handle files in the ->in() call.
     $files = array_filter($paths, function ($possible_file) {
         return is_file($possible_file);
     });
     //Filter out the directories to be used for searching using the Filter class.
     $dirs = array_filter($paths, function ($possible_dir) {
         return is_dir($possible_dir);
     });
     $finder = new Finder();
     //Add the given 'stand-alone-files'
     $finder->append($files);
     //Add the Directores recursively
     $finder = $finder->in($dirs);
     //Filter out non readable files
     $finder = $finder->filter(function (SplFileInfo $finder) {
         return $finder->isReadable();
     });
     //Loop through all the files and save the latest modification time.
     foreach ($finder->files() as $file) {
         /*@var $file \SplFileInfo */
         if ($this->modification_time < $file->getMTime()) {
             $this->modification_time = $file->getMTime();
         }
     }
 }
开发者ID:hostnet,项目名称:webpack-bundle,代码行数:32,代码来源:TrackedFiles.php

示例2: getFileIterator

 /**
  * @param $path
  * @param $extensions
  * @return Finder
  */
 protected function getFileIterator($path, $extensions)
 {
     $fileInfo = new SplFileInfo($path);
     $finder = new Finder();
     if ($fileInfo->isFile()) {
         return $finder->append(array($fileInfo));
     }
     return $finder->files()->in($path)->name('/\\.(' . implode('|', $extensions) . ')$/i');
 }
开发者ID:netz98,项目名称:magniffer,代码行数:14,代码来源:Command.php

示例3: serveMarkdown

 public function serveMarkdown($mdFile)
 {
     $basePath = dirname($mdFile) . '/' . basename($mdFile, '.md');
     $source = new Finder();
     $source->append([$mdFile]);
     if (is_dir($basePath)) {
         $children = new Finder();
         $children->in($basePath)->name('*.md')->sortByName();
         $source->append($children);
     }
     $merger = new Merge();
     $content = $merger->mergeFiles($source, $basePath);
     $converter = new Converter();
     $html = $converter->toHtml($content);
     EventManager::dispatch('preHeader');
     header('Content-Type: text/html; charset=utf-8');
     EventManager::dispatch('html', $html);
 }
开发者ID:sourcerer-mike,项目名称:mdoc,代码行数:18,代码来源:Server.php

示例4: findPHPFilesByPath

 /**
  * Find all php files by path.
  *
  * @param string $path Path
  *
  * @return Finder Finder iterable object with all PHP found files in path
  */
 public function findPHPFilesByPath($path)
 {
     $finder = new Finder();
     if (file_exists($path) && !is_dir($path)) {
         $finder->append([0 => $path]);
     } else {
         $finder->files()->in($path)->name('*.php');
     }
     return $finder;
 }
开发者ID:mmoreram,项目名称:php-formatter,代码行数:17,代码来源:FileFinder.php

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

示例6: getFiles

 public function getFiles()
 {
     $finder = new Finder();
     try {
         $finder->in($this->getFindPath())->files();
     } catch (\InvalidArgumentException $e) {
         //catch non-existing directory exception.
         //This can happen if getFiles is called and no file has yet been uploaded
         //push empty array into the finder so we can emulate no files found
         $finder->append(array());
     }
     return $finder;
 }
开发者ID:czifumasa,项目名称:Inzynierka5,代码行数:13,代码来源:FilesystemOrphanageStorage.php

示例7: createFromArray

 protected function createFromArray(array $paths)
 {
     $finder = new Finder();
     $files = [];
     $dirs = [];
     foreach ($paths as $path) {
         if (is_file($path)) {
             $files[] = $path;
             continue;
         }
         $dirs[] = $path;
     }
     return $finder->append($files)->in($dirs);
 }
开发者ID:schnittstabil,项目名称:finder-by-config,代码行数:14,代码来源:FinderByConfig.php

示例8: execute

 /**
  * {@inheritdoc}
  */
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $finder = new Finder();
     $path = $input->getOption('cwd');
     if (file_exists($path) && !is_dir($path)) {
         $finder->append([0 => $path]);
     } else {
         $finder->files()->in($path)->name('*.php');
     }
     $license = $this->getLicenseText($input->getOption('package'), $input->getOption('author'));
     $t = 0;
     foreach ($finder as $file) {
         $data = file_get_contents($file->getRealpath());
         $tokens = token_get_all($data);
         $content = '';
         $need_license = true;
         for ($i = 0, $c = count($tokens); $i < $c; ++$i) {
             if (!is_array($tokens[$i])) {
                 $content .= $tokens[$i];
                 continue;
             }
             if (T_DOC_COMMENT === $tokens[$i][0] && $this->isPHPStormLicense($tokens[$i][1])) {
                 // Delete Auto Generated PHPStorm comments
                 continue;
             } else {
                 if (T_COMMENT === $tokens[$i][0] && $this->isOldLicense($tokens[$i][1])) {
                     $content .= $license;
                     $need_license = false;
                 } else {
                     $content .= $tokens[$i][1];
                 }
             }
         }
         if ($need_license) {
             $content = preg_replace('/<\\?php/', "<?php\n\n" . trim($license) . "\n\n", $data, 1);
         }
         file_put_contents($file->getRealpath(), $content);
         $output->writeln(sprintf('[Modify] <comment>%s</comment>', $file->getPathname()));
         ++$t;
     }
     $output->writeln("<info>Command finished successfully. Licensified {$t} files.</info>");
 }
开发者ID:jumbojett,项目名称:licensify,代码行数:45,代码来源:LicensifyCommand.php

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

示例10: processContentFiles

 private function processContentFiles()
 {
     $includedFiles = [];
     $finder = new Finder();
     $finder->in($this->composeSubPath('content'))->notName('*.meta')->files();
     foreach ($this->params['include'] as $item) {
         if (is_dir($item)) {
             $finder->in($item);
         } elseif (is_file($item)) {
             $includedFiles[] = new SplFileInfo($item, '', pathinfo($item, PATHINFO_BASENAME));
         }
     }
     $finder->append($includedFiles);
     foreach ($this->params['exclude'] as $item) {
         $finder->notPath($item);
     }
     $this->processItems($finder, Item::TYPE_ITEM);
 }
开发者ID:spress,项目名称:spress,代码行数:18,代码来源:FilesystemDataSource.php

示例11: testAppendWithAnArray

 public function testAppendWithAnArray()
 {
     $finder = new Finder();
     $finder->files()->in(self::$tmpDir . DIRECTORY_SEPARATOR . 'foo');
     $finder->append($this->toAbsolute(array('foo', 'toto')));
     $this->assertIterator($this->toAbsolute(array('foo', 'foo/bar.tmp', 'toto')), $finder->getIterator());
 }
开发者ID:navassouza,项目名称:symfony,代码行数:7,代码来源:FinderTest.php

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

示例13: append

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


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