本文整理汇总了PHP中RecursiveDirectoryIterator::setInfoClass方法的典型用法代码示例。如果您正苦于以下问题:PHP RecursiveDirectoryIterator::setInfoClass方法的具体用法?PHP RecursiveDirectoryIterator::setInfoClass怎么用?PHP RecursiveDirectoryIterator::setInfoClass使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类RecursiveDirectoryIterator
的用法示例。
在下文中一共展示了RecursiveDirectoryIterator::setInfoClass方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: from
/**
* Create Pages object instance from path
*
* @param string $path
* @param array|callable $filter
* @param string $class
* @return \cms\Pages
*/
public static function from($path, $filter = ['index', '404'], $class = Page::class)
{
$iterator = new \RecursiveDirectoryIterator(realpath($path), \RecursiveDirectoryIterator::SKIP_DOTS);
if (class_exists($class)) {
$iterator->setInfoClass($class);
}
$filter = is_callable($filter) ? $filter : function (Page $item) use($filter) {
return $item->isValid((array) $filter);
};
return new self(new \RecursiveCallbackFilterIterator($iterator, $filter));
}
示例2: __construct
public function __construct(array $sources)
{
foreach ($sources as $source) {
if ($source instanceof \SplFileInfo) {
$this->children[] = $source;
} elseif (is_string($source) && ($source = realpath($source))) {
if (is_file($source)) {
$child = new SourceFileInfo($source);
$child->setInfoClass(SourceFileInfo::class);
$this->children[] = $child;
} elseif (is_dir($source)) {
$child = new \RecursiveDirectoryIterator($source);
$child->setInfoClass(SourceFileInfo::class);
$this->children[] = $child;
}
}
}
}
示例3: createIterator
/**
* create an iterator to iterate through the children
*
* @since 6-23-11
* @param string $regex
* @param integer $depth
* @return \Traversable
*/
public function createIterator($regex = '', $depth = -1)
{
$depth = (int) $depth;
$iterator = null;
if ($this->isDir()) {
if ($depth < 0 || $depth > 1) {
$iterator = new RecursiveDirectoryIterator($this->getPathname(), FilesystemIterator::CURRENT_AS_FILEINFO | FilesystemIterator::KEY_AS_PATHNAME | FilesystemIterator::SKIP_DOTS);
$iterator->setInfoClass(get_class($this));
$iterator = new RecursiveIteratorIterator($iterator, RecursiveIteratorIterator::SELF_FIRST);
$iterator->setMaxDepth($depth);
} else {
$iterator = new FilesystemIterator($this->getPathname(), FilesystemIterator::CURRENT_AS_FILEINFO | FilesystemIterator::KEY_AS_PATHNAME | FilesystemIterator::SKIP_DOTS);
$iterator->setInfoClass(get_class($this));
}
//if/else
} else {
$iterator = $this->openFile();
$iterator->setFlags(\SplFileObject::DROP_NEW_LINE | \SplFileObject::SKIP_EMPTY);
}
//if/else
if (!empty($regex)) {
$iterator = new RegexIterator($iterator, $regex, RegexIterator::MATCH);
}
//if/else
return $iterator;
}
示例4: createRecursiveDirectoryIterator
/**
* Создаёт объект RecursiveDirectoryIterator для текущей директории.
*
* @return RecursiveDirectoryIterator
*/
public function createRecursiveDirectoryIterator($flags = null)
{
if (isset($flags)) {
$iterator = new \RecursiveDirectoryIterator($this->getRealPath(), $flags);
} else {
$iterator = new \RecursiveDirectoryIterator($this->getRealPath());
}
$iterator->setFileClass('Stalxed\\FileSystem\\FileObject');
$iterator->setInfoClass('Stalxed\\FileSystem\\FileInfo');
return $iterator;
}