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


PHP RecursiveDirectoryIterator::getChildren方法代码示例

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


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

示例1: getCallableModules

 /**
  * get callable module list
  *
  * @return array
  */
 public function getCallableModules()
 {
     $dirIterator = new \RecursiveDirectoryIterator($this->path, \FilesystemIterator::NEW_CURRENT_AND_KEY | \FilesystemIterator::SKIP_DOTS);
     $modules = array();
     foreach ($dirIterator as $k => $v) {
         $doVotedModule = false;
         if ($dirIterator->hasChildren()) {
             foreach ($dirIterator->getChildren() as $key => $value) {
                 $entension = $value->getExtension();
                 if (!$entension || 'php' !== $entension) {
                     continue;
                 }
                 $fileBasename = $value->getBasename('.php');
                 $module_to_be = $v->getBasename();
                 $expectedClassName = $this->baseNamespace . NAMESPACE_SEPARATOR . $module_to_be . NAMESPACE_SEPARATOR . $fileBasename;
                 Loader::getInstance()->import($value->__toString());
                 if (!class_exists($expectedClassName, false)) {
                     // not a standard class file!
                     continue;
                 }
                 if (!$doVotedModule) {
                     $modules[] = $module_to_be;
                     $doVotedModule = true;
                 }
             }
         }
     }
     return $modules;
 }
开发者ID:TF-Joynic,项目名称:Hydrogen,代码行数:34,代码来源:ConsoleHelper.php

示例2: getChildren

 /**
  * @return mixed object
  *
  * @throws AccessDeniedException
  */
 public function getChildren()
 {
     try {
         return parent::getChildren();
     } catch (\UnexpectedValueException $e) {
         throw new AccessDeniedException($e->getMessage(), $e->getCode(), $e);
     }
 }
开发者ID:nfabre,项目名称:symfony,代码行数:13,代码来源:RecursiveDirectoryIterator.php

示例3: getChildren

 /** Override of getChildren in \RecursiveDirectoryIterator, to skip directories with insufficient rights to access
  * @internal
  */
 function getChildren()
 {
     try {
         return parent::getChildren();
     } catch (\UnexpectedValueException $e) {
         return new \RecursiveArrayIterator(array());
     }
 }
开发者ID:zhengxiexie,项目名称:wordpress,代码行数:11,代码来源:IgnorantRecursiveDirectoryIterator.php

示例4: getChildren

 public function getChildren()
 {
     $children = parent::getChildren();
     if (is_object($children)) {
         echo get_class($children) . " {$children}\n";
     } else {
         echo gettype($children) . " {$children}\n";
     }
     return $children;
 }
开发者ID:gleamingthecube,项目名称:php,代码行数:10,代码来源:ext_spl_tests_bug66405.php

示例5: getChildren

 /**
  * @return \RecursiveIterator
  *
  * @throws AccessDeniedException
  */
 public function getChildren()
 {
     try {
         return parent::getChildren();
     } catch (\UnexpectedValueException $e) {
         if ($this->ignoreUnreadableDirs) {
             // If directory is unreadable and finder is set to ignore it, a fake empty content is returned.
             return new \RecursiveArrayIterator(array());
         } else {
             throw new AccessDeniedException($e->getMessage(), $e->getCode(), $e);
         }
     }
 }
开发者ID:TuxCoffeeCorner,项目名称:tcc,代码行数:18,代码来源:RecursiveDirectoryIterator.php

示例6: getChildren

 public function getChildren()
 {
     try {
         $children = parent::getChildren();
         if ($children instanceof self) {
             $children->skipUnreadable = $this->skipUnreadable;
         }
         return $children;
     } catch (\UnexpectedValueException $e) {
         if ($this->skipUnreadable) {
             return new \RecursiveArrayIterator(array());
         } else {
             throw new \Reea\FileSearcher\Bundle\Exceptions\AccessDeniedException();
         }
     }
 }
开发者ID:florinmatthew,项目名称:find-file-content,代码行数:16,代码来源:RecursiveDirectoryIterator.php

示例7: getChildren

 public function getChildren()
 {
     try {
         $children = parent::getChildren();
         if ($children instanceof self) {
             $children->ignoreUnreadableDirs = $this->ignoreUnreadableDirs;
         }
         return $children;
     } catch (\UnexpectedValueException $e) {
         if ($this->ignoreUnreadableDirs) {
             return new \RecursiveArrayIterator(array());
         } else {
             throw new AccessDeniedException($e->getMessage(), $e->getCode(), $e);
         }
     }
 }
开发者ID:VicDeo,项目名称:poc,代码行数:16,代码来源:RecursiveDirectoryIterator.php

示例8: import

 /**
  * import
  *
  * @param string $tsvDirPath
  * @access public
  * @return void
  */
 public function import($tsvDirPath = null)
 {
     if (is_null($tsvDirPath)) {
         $tsvDirPath = realpath(__DIR__ . '/../../../../../../masterData');
     }
     $iterator = new \RecursiveDirectoryIterator($tsvDirPath);
     foreach ($iterator as $file) {
         if (!$iterator->hasChildren()) {
             continue;
         }
         $databaseName = $file->getFileName();
         $con = $this->getConnection($databaseName);
         $con->exec('set foreign_key_checks = 0');
         $this->importFromTsvInDir($iterator->getChildren(), $con);
         $con->exec('set foreign_key_checks = 1');
     }
 }
开发者ID:magical-yuri,项目名称:magical-girl,代码行数:24,代码来源:MasterDBImporter.php

示例9: getChildren

 /**
  * @return \RecursiveIterator
  *
  * @throws AccessDeniedException
  */
 public function getChildren()
 {
     try {
         $children = parent::getChildren();
         if ($children instanceof self) {
             // parent method will call the constructor with default arguments, so unreadable dirs won't be ignored anymore
             $children->ignoreUnreadableDirs = $this->ignoreUnreadableDirs;
         }
         return $children;
     } catch (\UnexpectedValueException $e) {
         if ($this->ignoreUnreadableDirs) {
             // If directory is unreadable and finder is set to ignore it, a fake empty content is returned.
             return new \RecursiveArrayIterator(array());
         } else {
             throw new AccessDeniedException($e->getMessage(), $e->getCode(), $e);
         }
     }
 }
开发者ID:burimshala,项目名称:numbertowords,代码行数:23,代码来源:RecursiveDirectoryIterator.php

示例10: load_tests

 private function load_tests(RecursiveDirectoryIterator $dir)
 {
     while ($dir->valid()) {
         $current = $dir->current();
         if ($dir->isFile() && preg_match("/(.)Test\\.php\$/", $current->getFilename(), $matches)) {
             // XXX: handle errors
             include $current->getPathname();
             $x = explode('.', $current->getFilename());
             $class = $x[0];
             $rclass = new ReflectionClass($class);
             if ($rclass->getParentClass()->getName() == 'UnitTest') {
                 $this->cases[] = $rclass;
             }
         } elseif ($dir->hasChildren() && preg_match("/^\\./", $current->getFilename(), $matches) == 0) {
             $this->load_tests($dir->getChildren());
         }
         $dir->next();
     }
 }
开发者ID:BackupTheBerlios,项目名称:medick-svn,代码行数:19,代码来源:TestRunner.php

示例11: getChildren

 /**
  * @return RecursiveIterator
  *
  * @throws (ehough_finder_exception_AccessDeniedException
  */
 public function getChildren()
 {
     try {
         $children = parent::getChildren();
         if ($children instanceof self) {
             // parent method will call the constructor with default arguments, so unreadable dirs won't be ignored anymore
             $children->ignoreUnreadableDirs = $this->ignoreUnreadableDirs;
             // performance optimization to avoid redoing the same work in all children
             $children->rewindable =& $this->rewindable;
             $children->rootPath = $this->rootPath;
         }
         return $children;
     } catch (UnexpectedValueException $e) {
         if ($this->ignoreUnreadableDirs) {
             // If directory is unreadable and finder is set to ignore it, a fake empty content is returned.
             return new RecursiveArrayIterator(array());
         } else {
             if (version_compare(PHP_VERSION, '5.3') >= 0) {
                 throw new ehough_finder_exception_AccessDeniedException($e->getMessage(), $e->getCode(), $e);
             }
             throw new ehough_finder_exception_AccessDeniedException($e->getMessage(), $e->getCode());
         }
     }
 }
开发者ID:ehough,项目名称:finder,代码行数:29,代码来源:RecursiveDirectoryIterator.php

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

示例13: loadCommands

 /**
  * Load all Command files from $path directory.
  *
  * Traverse all files inside specified directory, but loads only those files with suffix 'Command.php'.
  *
  * @param string      $path   Directory with Command files
  * @param string|null $prefix Commands namespace
  *
  * @return void
  */
 public function loadCommands($path, $prefix = null)
 {
     // load commands
     try {
         $iterator = new \RecursiveDirectoryIterator($path, \FilesystemIterator::KEY_AS_PATHNAME | \FilesystemIterator::CURRENT_AS_FILEINFO);
         /** @var \RecursiveDirectoryIterator $child */
         foreach ($iterator->getChildren() as $child) {
             if ($child->isFile() && \preg_match('/Command.php$/', $child->getBasename())) {
                 $namespace = $class = "";
                 $gettingNamespace = $gettingClass = false;
                 foreach (\token_get_all(\file_get_contents($child->getRealPath())) as $token) {
                     if (\is_array($token) && ($token[0] === T_ABSTRACT || $token[0] === T_INTERFACE)) {
                         $namespace = $class = '';
                         break;
                     }
                     if (\is_array($token) && $token[0] === T_NAMESPACE) {
                         $gettingNamespace = true;
                     }
                     if (\is_array($token) && $token[0] === T_CLASS) {
                         $gettingClass = true;
                     }
                     if ($gettingNamespace === true) {
                         if (\is_array($token) && \in_array($token[0], [T_STRING, T_NS_SEPARATOR])) {
                             $namespace .= $token[1];
                         } else {
                             if ($token === ';') {
                                 $gettingNamespace = false;
                             }
                         }
                     }
                     if ($gettingClass === true) {
                         if (\is_array($token) && $token[0] === T_STRING) {
                             $class = $token[1];
                             break;
                         }
                     }
                 }
                 $className = $namespace ? $namespace . '\\' . $class : $class;
                 if (\preg_match('/Command$/', $className) > 0) {
                     // make sure file with class is loaded
                     require_once $child->getRealPath();
                     /** @var Command $command */
                     $command = new $className();
                     if ($prefix !== null) {
                         $command->setName($prefix . ':' . $command->getName());
                     }
                     $this['console']->add($command);
                 }
             }
         }
     } catch (\UnexpectedValueException $ex) {
         // do nothing - no commands to load
     }
 }
开发者ID:dszczer,项目名称:Minion,代码行数:64,代码来源:Console.php

示例14: getChildren

 /**
  * (PHP 5 &gt;= 5.1.0)<br/>
  * Return the inner iterator's children contained in a RecursiveFilterIterator
  *
  * @link http://php.net/manual/en/recursivefilteriterator.getchildren.php
  * @return \RecursiveFilterIterator containing the inner iterator's children.
  */
 public function getChildren()
 {
     return new self($this->iterator->getChildren(), $this->excluded);
 }
开发者ID:quilam,项目名称:oauth2-ringplus,代码行数:11,代码来源:Manager.php

示例15: toArray

 /**
  * Recursively convert RecursiveDirectoryIterator to array
  *
  * @param \RecursiveDirectoryIterator $tree
  * @param string $path
  * @return array
  */
 protected function toArray(\RecursiveDirectoryIterator $tree, $path)
 {
     $array = array();
     $types = array();
     $names = array();
     foreach ($tree as $file) {
         if (strpos($file->getFileName(), '.') === 0) {
             continue;
         }
         $types[] = (int) $file->isDir();
         $names[] = $file->getFileName();
         $array[] = $entry = array('type' => $file->isDir() ? 'folder' : 'file', 'name' => $file->getFileName(), 'path' => $localPath = str_replace($this->source, '', $file->getPath() . '/' . $file->getFileName()), 'children' => $tree->hasChildren() ? $this->toArray($tree->getChildren(), $path) : array(), 'state' => strpos($path, $localPath) === 0 ? 'open' : 'close');
     }
     array_multisort($types, SORT_NUMERIC, SORT_DESC, $names, SORT_STRING, SORT_ASC, $array);
     return $array;
 }
开发者ID:JanPietrzyk,项目名称:review,代码行数:23,代码来源:Source.php


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