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


PHP Finder::path方法代码示例

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


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

示例3: doAddPattern

 /**
  * Action for Add an ignore pattern.
  *
  * @param string $pattern The pattern
  */
 public function doAddPattern($pattern)
 {
     if (0 === strpos($pattern, '!')) {
         $this->finder->notPath(Glob::toRegex(substr($pattern, 1), true, false));
     } else {
         $this->finder->path(Glob::toRegex($pattern, true, false));
     }
 }
开发者ID:pombredanne,项目名称:ArcherSys,代码行数:13,代码来源:IgnoreManager.php

示例4: convertPatternStep2

 /**
  * Step2: Converter pattern to glob.
  *
  * @param string $prefix        The prefix
  * @param string $searchPattern The search pattern
  * @param string $pattern       The pattern
  */
 protected function convertPatternStep2($prefix, $searchPattern, $pattern)
 {
     if ('.*' === $searchPattern) {
         $this->doAddPattern($prefix . '**/.*');
     } elseif ('**' === $searchPattern) {
         $this->finder->path('/.*/');
         $this->finder->notPath('/^\\..*(?!\\/)/');
     } elseif (preg_match('/\\/\\*$|\\/\\*\\*$/', $pattern, $matches)) {
         $this->doAddPattern(substr($pattern, 0, strlen($pattern) - strlen($matches[0])));
     }
 }
开发者ID:stefangr,项目名称:composer-asset-plugin,代码行数:18,代码来源:IgnoreManager.php

示例5: getItems

 public function getItems(array $include, array $exclude)
 {
     $finder = new Finder();
     $finder->in($this->getRootPath());
     foreach ($include as $path) {
         $finder->path($this->normalizePath($path));
     }
     foreach ($exclude as $path) {
         $finder->notPath($this->normalizePath($path));
     }
     $items = [];
     foreach ($finder as $resource) {
         $items[] = $this->loadItem($resource);
     }
     return $items;
 }
开发者ID:jmfontaine,项目名称:projectlint,代码行数:16,代码来源:ItemManager.php

示例6: appShareClassHelper

 /**
  * Quick helper function for automatic class share in Silex
  *
  * @param string $searchDirectory Directory to scan for php classes
  * @param string $nameEndWith     End string to find in the name to consider the class as valid
  *                                Example : for classes of type 'UserController', set 'Controller' for this parameter
  * @param string $pathFilter      Path filter (optional)
  *                                Usage example : we want to add the condition that the path contains a folder 'Controllers'
  * @param bool   $useCache        Use cache feature or not
  * @param string $cacheDir        Cache directory to use ('app/cache' by default)
  *
  * @return array
  */
 public static function appShareClassHelper($searchDirectory, $nameEndWith, $pathFilter, $useCache = true, $cacheDir = 'app/cache')
 {
     if ($useCache) {
         if (file_exists($cacheDir . '/shares/' . strtolower($nameEndWith) . '.log')) {
             return unserialize(file_get_contents($cacheDir . '/shares/' . strtolower($nameEndWith) . '.log'));
         }
     }
     if (!file_exists($searchDirectory)) {
         return false;
     }
     $shares = array();
     $classFinder = new Finder();
     $searchDirectory = realpath($searchDirectory);
     $cacheDir = realpath($cacheDir);
     $fileNameFilter = $nameEndWith;
     if (false === strripos($fileNameFilter, '.php')) {
         $fileNameFilter .= '.php';
     }
     $classFinder->files()->name('*' . $fileNameFilter);
     if (!empty($pathFilter)) {
         $classFinder->path('/' . $pathFilter . '/');
     }
     $classFinder->in($searchDirectory);
     /**
      * @var SplFileInfo $classFile
      */
     foreach ($classFinder as $classFile) {
         $key = strtolower(str_replace($fileNameFilter, '', $classFile->getFilename()));
         if (!empty($key)) {
             $className = str_replace('.php', '', $classFile->getFilename());
             $classFQCN = str_replace(realpath($searchDirectory) . DIRECTORY_SEPARATOR, '', realpath($classFile->getPath()));
             $classFQCN = str_replace('/', '\\', $classFQCN) . '\\' . $className;
             $shares[$key . '.' . strtolower($nameEndWith)] = $classFQCN;
         }
     }
     if ($useCache) {
         if (!file_exists($cacheDir . '/shares')) {
             mkdir($cacheDir . '/shares', 0755, true);
         }
         if (!file_exists($cacheDir . '/shares/' . strtolower($nameEndWith) . '')) {
             file_put_contents($cacheDir . '/shares/' . strtolower($nameEndWith) . '', serialize($shares));
         }
     }
     return $shares;
 }
开发者ID:sylvaincombes,项目名称:firecamp-php,代码行数:58,代码来源:Utils.php

示例7: process

 public function process($professorName = null, $path = null)
 {
     if ($professorName === null) {
         $this->processAll();
     } else {
         $professor = $this->getProfessor($professorName);
         if ($path === null) {
             $photos = $this->findAll();
             $arr = [];
             foreach ($photos as $photo) {
                 $dest = $this->baseCacheDestination . '/' . $professor->name . '/' . $photo->getRelativePathname();
                 $arr[] = $dest;
                 $this->processSingleFile($photo->getRealPath(), $dest, $professor->transformFunction, $professor->transformClass);
             }
             $this->lastProcessedFiles = $arr;
         } else {
             $photos = new Finder();
             $photos->files()->in($this->basePath);
             $pathBase = dirname($path);
             if ($pathBase !== '.') {
                 $photos->path($pathBase);
             }
             $photos->name(basename($path));
             foreach ($photos as $photo) {
                 if (preg_match($this->extenstions, $photo->getRealPath())) {
                     $dest = $this->baseCacheDestination . '/' . $professor->name . '/' . $photo->getRelativePathname();
                     $this->lastProcessedFiles = $dest;
                     $this->processSingleFile($photo->getRealPath(), $dest, $professor->transformFunction, $professor->transformClass);
                 } else {
                     return false;
                 }
             }
         }
     }
     return $this;
 }
开发者ID:maciekpaprocki,项目名称:imageprofessor,代码行数:36,代码来源:Faculty.php

示例8: getOroFixturesList

 /**
  * Get the Oro fixtures list
  *
  * @return array
  */
 protected function getOroFixturesList()
 {
     $bundles = $this->getContainer()->getParameter('kernel.bundles');
     $basePath = realpath($this->getContainer()->getParameter('kernel.root_dir') . DIRECTORY_SEPARATOR . '..');
     $finder = new Finder();
     foreach ($bundles as $bundleName => $bundleNamespace) {
         if (strpos($bundleNamespace, 'Oro\\') === 0) {
             $bundle = $this->getContainer()->get('kernel')->getBundle($bundleName);
             $finder->in($bundle->getPath());
         }
     }
     // Oro User Bundle overriden by Pim User Bundle, but we still need the data fixtures inside OroUserBundle
     $finder->in($basePath . "/vendor/oro/platform/src/Oro/Bundle/UserBundle");
     $directories = $finder->path('/^DataFixtures$/')->directories();
     $oroFixtures = array();
     foreach ($directories as $directory) {
         $oroFixtures[] = $directory->getPathName();
     }
     return $oroFixtures;
 }
开发者ID:javiersantos,项目名称:pim-community-dev,代码行数:25,代码来源:DatabaseCommand.php

示例9: getTempFolders

 /**
  * @return Finder
  */
 public function getTempFolders()
 {
     $finder = new Finder();
     $sysPath = $this->getSysPath();
     $finder->directories()->in($sysPath);
     $finder->path('archive');
     $finder->path('data/temp');
     return $finder;
 }
开发者ID:ilosada,项目名称:chamilo-lms-icpna,代码行数:12,代码来源:ConfigurationHelper.php

示例10: json_encode

$directoryIterator = $directoryFinder->in($path->path);
$directoryArray = array();
foreach ($directoryIterator as $directory) {
    $directoryArray[] = array("path" => $directory->getRelativePathname(), "name" => $directory->getBasename());
}
$fileFinder = new Finder();
$fileFinder->files()->ignoreUnreadableDirs()->depth(0);
$allowedImageTypes = loadPicFile("helpers/imagetypes.php");
foreach ($allowedImageTypes as $imageType) {
    $fileFinder->name("*.{$imageType}");
}
foreach (array_map("strtoupper", $allowedImageTypes) as $imageType) {
    $fileFinder->name("*.{$imageType}");
}
$fileFinder->sortByName();
if ($path->hasPermission("symlinks")) {
    $fileFinder->followLinks();
}
if (!empty($relpath)) {
    $fileFinder->path($relpath)->depth(substr_count($relpath, "/") + 1);
}
if ($path->hasPermission("nsfw") === false) {
    $fileFinder->notPath("/.*\\/NSFW\\/.*/")->notPath("/NSFW\\/.*/")->notPath("/.*\\/NSFW/");
}
$fileIterator = $fileFinder->in($path->path);
$fileArray = array();
foreach ($fileIterator as $file) {
    $fileArray[] = array("filename" => $file->getBasename(), "relpath" => $file->getRelativePathname(), "size" => humanFilesize($file->getSize()), "mtime" => date("Y-m-d H:i:s", $file->getMTime()));
}
header("Content-type: application/json");
echo json_encode(array("directories" => $directoryArray, "files" => $fileArray));
开发者ID:djmattyg007,项目名称:pictorials,代码行数:31,代码来源:filebrowser.php

示例11: apply

 /**
  * Apply configuration to finder
  *
  * @param Finder $finder
  */
 public function apply(Finder $finder)
 {
     $finder->exclude($this->excludeDirs);
     foreach ($this->excludePaths as $pattern) {
         $finder->notPath($pattern);
     }
     foreach ($this->excludeFiles as $pattern) {
         $finder->notName($pattern);
     }
     $finder->in($this->includeDirs);
     foreach ($this->includePaths as $pattern) {
         $finder->path($pattern);
     }
     foreach ($this->includeFiles as $pattern) {
         $finder->name($pattern);
     }
 }
开发者ID:sunnyct,项目名称:phar-compiler,代码行数:22,代码来源:Configuration.php

示例12: createFinder

 /**
  * @param  InputInterface $input
  * @return Finder
  */
 public function createFinder(InputInterface $input)
 {
     $finder = new Finder();
     $finder->files();
     foreach ($input->getArgument('directory') as $dir) {
         $finder->in($dir);
     }
     foreach ($input->getOption('not-dir') as $ignoreDir) {
         $finder->exclude($ignoreDir);
     }
     foreach ($input->getOption('file-name') as $pattern) {
         $finder->name($pattern);
     }
     foreach ($input->getOption('not-file-name') as $pattern) {
         $finder->notName($pattern);
     }
     foreach ($input->getOption('contains') as $pattern) {
         $finder->contains($pattern);
     }
     foreach ($input->getOption('not-contains') as $pattern) {
         $finder->notContains($pattern);
     }
     foreach ($input->getOption('path') as $pattern) {
         $finder->path($pattern);
     }
     foreach ($input->getOption('not-path') as $pattern) {
         $finder->notPath($pattern);
     }
     if ($size = $input->getOption('size')) {
         $finder->size($size);
     }
     if ($modified = $input->getOption('modified')) {
         $finder->date($modified);
     }
     if ($depth = $input->getOption('depth')) {
         $finder->depth($depth);
     }
     return $finder;
 }
开发者ID:hanneskod,项目名称:phpfind,代码行数:43,代码来源:Command.php

示例13: getConfigFolders

 /**
  * @return Finder
  */
 public function getConfigFolders()
 {
     $finder = new Finder();
     $sysPath = $this->getSysPath();
     $finder->directories()->in($sysPath);
     $finder->path('main/inc/conf');
     $finder->path('app/config');
     return $finder;
 }
开发者ID:chamilo,项目名称:chash,代码行数:12,代码来源:ConfigurationHelper.php

示例14: path

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


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