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


PHP RecursiveDirectoryIterator::getSubPathname方法代码示例

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


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

示例1: getExamples

 /**
  * Data provider for testExamples method.
  *
  * Assumes that an `examples` directory exists inside parent directory.
  * This examples directory should contain any number of subdirectories, each of which contains
  * three files: one Mustache class (.php), one Mustache template (.mustache), and one output file
  * (.txt).
  *
  * This whole mess will be refined later to be more intuitive and less prescriptive, but it'll
  * do for now. Especially since it means we can have unit tests :)
  *
  * @access public
  * @return array
  */
 public function getExamples()
 {
     $basedir = dirname(__FILE__) . '/../examples/';
     $ret = array();
     $files = new RecursiveDirectoryIterator($basedir);
     while ($files->valid()) {
         if ($files->hasChildren() && ($children = $files->getChildren())) {
             $example = $files->getSubPathname();
             $class = null;
             $template = null;
             $output = null;
             foreach ($children as $file) {
                 if (!$file->isFile()) {
                     continue;
                 }
                 $filename = $file->getPathInfo();
                 $info = pathinfo($filename);
                 switch ($info['extension']) {
                     case 'php':
                         $class = $info['filename'];
                         include_once $filename;
                         break;
                     case 'mustache':
                         $template = file_get_contents($filename);
                         break;
                     case 'txt':
                         $output = file_get_contents($filename);
                         break;
                 }
             }
             $ret[$example] = array($class, $template, $output);
         }
         $files->next();
     }
     return $ret;
 }
开发者ID:kennethreitz-archive,项目名称:wp-mustache,代码行数:50,代码来源:MustacheTest.php

示例2: parseDir

 /**
  * parse this directory
  *
  * @return  none
  */
 protected function parseDir()
 {
     $this->clear();
     $iter = new RecursiveDirectoryIterator($this->getPath());
     while ($iter->valid()) {
         $curr = (string) $iter->getSubPathname();
         if (!$iter->isDot() && $curr[0] != '.') {
             $this->addItem(Varien_Directory_Factory::getFactory($iter->current(), $this->getRecursion(), $this->getRecursionLevel()));
         }
         $iter->next();
     }
 }
开发者ID:natxetee,项目名称:magento2,代码行数:17,代码来源:Collection.php


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