doc: Use Icinga Web 2's iterators

This commit is contained in:
Eric Lippmann 2014-12-09 12:29:48 +01:00
parent 1afc2a0b1d
commit 5f772c3620
1 changed files with 8 additions and 4 deletions

View File

@ -9,6 +9,8 @@ use Countable;
use IteratorAggregate; use IteratorAggregate;
use RecursiveIteratorIterator; use RecursiveIteratorIterator;
use RecursiveDirectoryIterator; use RecursiveDirectoryIterator;
use Icinga\File\NonEmptyFileIterator;
use Icinga\File\FileExtensionFilterIterator;
/** /**
* Iterator over non-empty Markdown files ordered by the case insensitive "natural order" of file names * Iterator over non-empty Markdown files ordered by the case insensitive "natural order" of file names
@ -29,12 +31,14 @@ class DocIterator implements Countable, IteratorAggregate
*/ */
public function __construct($path) public function __construct($path)
{ {
$it = new RecursiveIteratorIterator( $it = new FileExtensionFilterIterator(
new NonEmptyFileIterator( new NonEmptyFileIterator(
new MarkdownFileIterator( new RecursiveIteratorIterator(
new RecursiveDirectoryIterator($path) new RecursiveDirectoryIterator($path),
RecursiveIteratorIterator::SELF_FIRST
) )
) ),
'md'
); );
// Unfortunately we have no chance to sort the iterator // Unfortunately we have no chance to sort the iterator
$fileInfo = iterator_to_array($it); $fileInfo = iterator_to_array($it);