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


PHP Finder::followLinks方法代码示例

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


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

示例1: __construct

 public function __construct()
 {
     $themes = Kernel::getService('em')->getRepository('RZ\\Roadiz\\Core\\Entities\\Theme')->findAll();
     $choices = [];
     $finder = new Finder();
     // Extracting the PHP files from every Theme folder
     $iterator = $finder->followLinks()->files()->name('config.yml')->depth(1)->in(ROADIZ_ROOT . '/themes');
     // And storing it into an array, used in the form
     foreach ($iterator as $file) {
         $data = Yaml::parse($file->getPathname());
         $classname = '\\Themes\\' . $data['themeDir'] . "\\" . $data['themeDir'] . "App";
         /*
          * Parsed file is not or does not contain any PHP Class
          * Bad Theme !
          */
         $choices[$classname] = $data['name'];
     }
     foreach ($themes as $theme) {
         if (array_key_exists($theme->getClassName(), $choices)) {
             unset($choices[$theme->getClassName()]);
         }
         if (array_key_exists(Kernel::INSTALL_CLASSNAME, $choices)) {
             unset($choices[Kernel::INSTALL_CLASSNAME]);
         }
     }
     $this->choices = $choices;
 }
开发者ID:QuangDang212,项目名称:roadiz,代码行数:27,代码来源:ThemesType.php

示例2: loadContext

 /**
  * loadContext
  *
  * @return array
  */
 private function loadContext()
 {
     $this->files = new Finder();
     $this->baseDir = new SplFileInfo($this->get('spliced_cms.site_manager')->getCurrentAdminSite()->getRootDir(), '/', '/');
     if ($this->get('request')->query->has('dir')) {
         $path = $this->baseDir->getRealPath() . '/' . $this->get('request')->query->get('dir');
         $relativePath = preg_replace('/\\/{2,}/', '/', str_replace($this->baseDir->getRealPath(), '', $path));
         $this->dir = new SplFileInfo($path, $relativePath, $relativePath);
     } else {
         $this->dir = $this->baseDir;
     }
     $this->files->followLinks()->depth(0)->in($this->dir->getRealPath());
     $this->file = null;
     if ($this->get('request')->query->has('file') && $this->get('request')->query->get('file')) {
         $this->file = new SplFileInfo($this->dir->getRealPath() . '/' . $this->get('request')->query->get('file'), $this->dir->getRelativePath() . '/' . $this->get('request')->query->get('file'), $this->dir->getRelativePathname());
     }
     $this->loaded = true;
     return $this;
 }
开发者ID:splicedmedia,项目名称:cms-bundle,代码行数:24,代码来源:FileManagementController.php

示例3: get_content

/**
 * Retrieve directory content, directories and files
 *
 * @param Application $app Silex Application
 * @param Request $request Request parameters
 *
 * @return JsonResponse Array of objects
 */
function get_content(Application $app, Request $request)
{
    $dirpath = Utils\check_path($app['cakebox.root'], $request->get('path'));
    if (!isset($dirpath)) {
        $app->abort(400, "Missing parameters");
    }
    $finder = new Finder();
    $finder->followLinks()->depth('< 1')->in("{$app['cakebox.root']}/{$dirpath}")->ignoreVCS(true)->ignoreDotFiles($app['directory.ignoreDotFiles'])->notName($app["directory.ignore"])->sortByType();
    $dirContent = [];
    foreach ($finder as $file) {
        if ($file->isLink()) {
            $linkTo = readlink("{$app['cakebox.root']}/{$dirpath}/{$file->getBasename()}");
            if (file_exists($linkTo) == false) {
                continue;
            }
            $file = new \SplFileInfo($linkTo);
        }
        $pathInfo = [];
        $pathInfo["name"] = $file->getBasename();
        $pathInfo["type"] = $file->getType();
        $pathInfo["mtime"] = $file->getMTime();
        $pathInfo["size"] = Utils\get_size($file);
        $pathInfo["access"] = str_replace('%2F', '/', rawurlencode("{$app['cakebox.access']}/{$dirpath}/{$file->getBasename()}"));
        $pathInfo["extraType"] = "";
        $ext = strtolower($file->getExtension());
        if (in_array($ext, $app["extension.video"])) {
            $pathInfo["extraType"] = "video";
        } else {
            if (in_array($ext, $app["extension.audio"])) {
                $pathInfo["extraType"] = "audio";
            } else {
                if (in_array($ext, $app["extension.image"])) {
                    $pathInfo["extraType"] = "image";
                } else {
                    if (in_array($ext, $app["extension.archive"])) {
                        $pathInfo["extraType"] = "archive";
                    } else {
                        if (in_array($ext, $app["extension.subtitle"])) {
                            $pathInfo["extraType"] = "subtitle";
                        }
                    }
                }
            }
        }
        array_push($dirContent, $pathInfo);
    }
    return $app->json($dirContent);
}
开发者ID:Arkhana,项目名称:Cakebox,代码行数:56,代码来源:directories.php

示例4: _findFiles

 private function _findFiles()
 {
     $finder = new Finder();
     $finder->files();
     foreach ($this->_excludePatterns as $excludePattern) {
         $finder->notName($excludePattern);
     }
     foreach ($this->_paths as $p) {
         $finder->in($p);
     }
     if ($this->_followLinks) {
         $finder->followLinks();
     }
     $files = array();
     foreach ($finder as $f) {
         $files[$f->getRealpath()] = array('mtime' => $f->getMTime(), 'perms' => $f->getPerms(), 'owner' => $f->getOwner(), 'group' => $f->getGroup());
     }
     return $files;
 }
开发者ID:koala-framework,项目名称:file-watcher,代码行数:19,代码来源:Poll.php

示例5: get_files

 /**
  * Returns a Finder instance for the files that will be included in the
  * backup.
  *
  * By default we ignore unreadable files and directories as well as, common
  * version control folders / files, "Dot" files and anything matching the
  * exclude rules.
  *
  * @uses Finder
  * @return Finder The Finder iterator of all files to be included
  */
 public function get_files()
 {
     $finder = new Finder();
     $finder->followLinks(true);
     $finder->ignoreDotFiles(false);
     $finder->ignoreVCS(true);
     $finder->ignoreUnreadableDirs(true);
     // Skip unreadable files too
     $finder->filter(function (\SplFileInfo $file) {
         if (!$file->isReadable()) {
             return false;
         }
     });
     // Finder expects exclude rules to be in a regex format
     $exclude_rules = $this->excludes->get_excludes_for_regex();
     // Skips folders/files that match default exclude patterns
     foreach ($exclude_rules as $exclude) {
         $finder->notPath($exclude);
     }
     return $finder->in(Path::get_root());
 }
开发者ID:AcademicTechnologyCenter,项目名称:ATC-Quality-Tracking,代码行数:32,代码来源:class-backup-engine-file.php

示例6: recursive_filesize_scanner

 /**
  * Recursively scans a directory to calculate the total filesize
  *
  * Locks should be set by the caller with `set_transient( 'hmbkp_directory_filesizes_running', true, HOUR_IN_SECONDS );`
  *
  * @return array $directory_sizes    An array of directory paths => filesize sum of all files in directory
  */
 public function recursive_filesize_scanner()
 {
     /**
      * Raise the `memory_limit` and `max_execution time`
      *
      * Respects the WP_MAX_MEMORY_LIMIT Constant and the `admin_memory_limit`
      * filter.
      */
     @ini_set('memory_limit', apply_filters('admin_memory_limit', WP_MAX_MEMORY_LIMIT));
     @set_time_limit(0);
     // Use the cached array directory sizes if available
     $directory_sizes = $this->get_cached_filesizes();
     // If we do have it in cache then let's use it and also clear the lock
     if (is_array($directory_sizes)) {
         delete_transient('hmbkp_directory_filesizes_running');
         return $directory_sizes;
     }
     // If we don't have it cached then we'll need to re-calculate
     $finder = new Finder();
     $finder->followLinks();
     $finder->ignoreDotFiles(false);
     $finder->ignoreUnreadableDirs(true);
     $files = $finder->in(Path::get_root());
     foreach ($files as $file) {
         if ($file->isReadable()) {
             $directory_sizes[wp_normalize_path($file->getRealpath())] = $file->getSize();
         } else {
             $directory_sizes[wp_normalize_path($file->getRealpath())] = 0;
         }
     }
     file_put_contents(PATH::get_path() . '/.files', gzcompress(json_encode($directory_sizes)));
     // Remove the lock
     delete_transient('hmbkp_directory_filesizes_running');
     return $directory_sizes;
 }
开发者ID:crazyyy,项目名称:bessarabia,代码行数:42,代码来源:class-site-size.php

示例7: get_files

 /**
  * Return an array of all files in the filesystem
  *
  * @return \RecursiveIteratorIterator
  */
 public function get_files()
 {
     $found = array();
     if (!empty($this->files)) {
         return $this->files;
     }
     $finder = new Finder();
     $finder->followLinks();
     $finder->ignoreDotFiles(false);
     $finder->ignoreUnreadableDirs();
     foreach ($this->default_excludes() as $exclude) {
         $finder->notPath($exclude);
     }
     foreach ($finder->in($this->get_root()) as $entry) {
         $this->files[] = $entry;
     }
     return $this->files;
 }
开发者ID:alexanderpetrob89,项目名称:fei.edu,代码行数:23,代码来源:class-backup.php

示例8: list_directory_by_total_filesize

 /**
  * Return the single depth list of files and subdirectories in $directory ordered by total filesize
  *
  * Will schedule background threads to recursively calculate the filesize of subdirectories.
  * The total filesize of each directory and subdirectory is cached in a transient for 1 week.
  *
  * @param string $directory The directory to scan
  *
  * @return array returns an array of files ordered by filesize
  */
 public function list_directory_by_total_filesize($directory)
 {
     $files = $files_with_no_size = $empty_files = $files_with_size = $unreadable_files = array();
     if (!is_dir($directory)) {
         return $files;
     }
     $found = array();
     if (!empty($this->files)) {
         return $this->files;
     }
     $default_excludes = $this->backup->default_excludes();
     $finder = new Finder();
     $finder->ignoreDotFiles(false);
     $finder->ignoreUnreadableDirs();
     $finder->followLinks();
     $finder->depth('== 0');
     foreach ($default_excludes as $exclude) {
         $finder->notPath($exclude);
     }
     foreach ($finder->in($directory) as $entry) {
         $files[] = $entry;
         // Get the total filesize for each file and directory
         $filesize = $this->filesize($entry);
         if ($filesize) {
             // If there is already a file with exactly the same filesize then let's keep increasing the filesize of this one until we don't have a clash
             while (array_key_exists($filesize, $files_with_size)) {
                 $filesize++;
             }
             $files_with_size[$filesize] = $entry;
         } elseif (0 === $filesize) {
             $empty_files[] = $entry;
         } else {
             $files_with_no_size[] = $entry;
         }
     }
     // Add 0 byte files / directories to the bottom
     $files = $files_with_size + array_merge($empty_files, $unreadable_files);
     // Add directories that are still calculating to the top
     if ($files_with_no_size) {
         // We have to loop as merging or concatenating the array would re-flow the keys which we don't want because the filesize is stored in the key
         foreach ($files_with_no_size as $entry) {
             array_unshift($files, $entry);
         }
     }
     return $files;
 }
开发者ID:alexanderpetrob89,项目名称:fei.edu,代码行数:56,代码来源:class-schedule.php

示例9: collectFiles

 /**
  * @param string $type
  * @param array  $items
  * @return array
  */
 public function collectFiles($type, $items)
 {
     $res = [];
     foreach ($items as $item) {
         $res[$item['exportName']] = [];
     }
     foreach ($items as $item) {
         $path = $item['path'];
         $exportName = $item['exportName'];
         if (is_file($path)) {
             if (($temp = strlen($path) - strlen($type)) >= 0 && strpos($path, $type, $temp) !== false) {
                 $res[$exportName][] = $path;
             }
         } else {
             $finder = new Finder();
             $finder->followLinks()->name('*.' . $type)->files()->in($path);
             foreach ($finder as $file) {
                 /** @var File $file */
                 $res[$exportName][] = ['realPath' => $file->getRealPath(), 'relativePathName' => $file->getRelativePathname(), 'relativePath' => $file->getRelativePath(), 'baseName' => $file->getBasename()];
             }
         }
     }
     return $res;
 }
开发者ID:tomfun,项目名称:js-templating-bundle,代码行数:29,代码来源:DumpProcessor.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: get_files

 /**
  * Return an array of all files in the filesystem.
  *
  * @param bool $ignore_default_exclude_rules If true then will return all files under root. Otherwise returns all files except those matching default exclude rules.
  *
  * @return array
  */
 public function get_files($ignore_default_exclude_rules = false)
 {
     $found = array();
     if (!empty($this->files)) {
         return $this->files;
     }
     $finder = new Finder();
     $finder->followLinks();
     $finder->ignoreDotFiles(false);
     $finder->ignoreUnreadableDirs();
     if (!$ignore_default_exclude_rules) {
         // Skips folders/files that match default exclude patterns
         foreach ($this->default_excludes() as $exclude) {
             $finder->notPath($exclude);
         }
     }
     foreach ($finder->in($this->get_root()) as $entry) {
         $this->files[] = $entry;
     }
     return $this->files;
 }
开发者ID:nvillapiano,项目名称:Xina,代码行数:28,代码来源:class-backup.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: scanFiles

 private function scanFiles($path, $parent)
 {
     $finder = new Finder();
     $finder->in($path);
     $finder->files();
     $finder->ignoreDotFiles(true);
     $finder->depth(0);
     $finder->sortByName();
     $finder->followLinks();
     $items = [];
     $index = null;
     foreach ($finder as $entity) {
         /* @var $entity SplFileInfo */
         $name = $entity->getFilename();
         // Skip items starting with underscore
         if (preg_match('~^_~', $name)) {
             continue;
         }
         // Skip items starting with dot
         if (preg_match('~^\\.~', $name)) {
             continue;
         }
         $isIndex = false;
         if (preg_match('~^index\\.~', basename($name))) {
             $isIndex = true;
         }
         $item = new RequestItem();
         $path = $entity->getPathname();
         $url = $this->relativePath . str_replace($this->path, '', $path);
         if ($isIndex) {
             $url = dirname($url) . '/';
             $index = $item;
             $this->scanFolders(dirname($path), $index);
         }
         $renderer = $this->staple->getRenderer($path);
         // Skip assets
         if (!$renderer instanceof NavigableInterface) {
             continue;
         }
         $data = (object) (new PreProcessor())->getData($this, $path, $entity->getBasename());
         $item->url = $url;
         $item->title = !empty($data->title) ? $data->title : '* ' . ucfirst(basename($url));
         $parent->items[] = $item;
     }
     return $index;
 }
开发者ID:maslosoft,项目名称:staple,代码行数:46,代码来源:SiteWalker.php

示例14: followLinks

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


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