From 5f772c36202422162ab4e40884f0b9a79759c040 Mon Sep 17 00:00:00 2001 From: Eric Lippmann Date: Tue, 9 Dec 2014 12:29:48 +0100 Subject: [PATCH] doc: Use Icinga Web 2's iterators --- modules/doc/library/Doc/DocIterator.php | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/modules/doc/library/Doc/DocIterator.php b/modules/doc/library/Doc/DocIterator.php index 43a9c7727..3045b6309 100644 --- a/modules/doc/library/Doc/DocIterator.php +++ b/modules/doc/library/Doc/DocIterator.php @@ -9,6 +9,8 @@ use Countable; use IteratorAggregate; use RecursiveIteratorIterator; 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 @@ -29,12 +31,14 @@ class DocIterator implements Countable, IteratorAggregate */ public function __construct($path) { - $it = new RecursiveIteratorIterator( + $it = new FileExtensionFilterIterator( new NonEmptyFileIterator( - new MarkdownFileIterator( - new RecursiveDirectoryIterator($path) + new RecursiveIteratorIterator( + new RecursiveDirectoryIterator($path), + RecursiveIteratorIterator::SELF_FIRST ) - ) + ), + 'md' ); // Unfortunately we have no chance to sort the iterator $fileInfo = iterator_to_array($it);