File tree Expand file tree Collapse file tree 4 files changed +22
-53
lines changed
Expand file tree Collapse file tree 4 files changed +22
-53
lines changed Original file line number Diff line number Diff line change 1616 ],
1717 "require" : {
1818 "php" : " 8.2 - 8.5" ,
19- "nette/utils" : " ^4.0"
19+ "nette/utils" : " ^4.0.10 "
2020 },
2121 "require-dev" : {
2222 "nette/tester" : " ^2.5" ,
Original file line number Diff line number Diff line change @@ -186,12 +186,13 @@ final public function getComponents(): iterable
186186 {
187187 $ filterType = func_get_args ()[1 ] ?? null ;
188188 if (func_get_args ()[0 ] ?? null ) { // back compatibility
189- $ iterator = new RecursiveComponentIterator ($ this ->components );
190- $ iterator = new \RecursiveIteratorIterator ($ iterator , \RecursiveIteratorIterator::SELF_FIRST );
191- if ($ filterType ) {
192- $ iterator = new \CallbackFilterIterator ($ iterator , fn ($ item ) => $ item instanceof $ filterType );
193- }
194- return $ iterator ;
189+ return Nette \Utils \Iterables::repeatable (function () use ($ filterType ) {
190+ foreach ($ this ->getComponentTree () as $ component ) {
191+ if (!$ filterType || $ component instanceof $ filterType ) {
192+ yield $ component ->getName () => $ component ;
193+ }
194+ }
195+ });
195196 }
196197
197198 return $ filterType
Load Diff This file was deleted.
Original file line number Diff line number Diff line change @@ -57,6 +57,15 @@ Assert::same([
5757 'two ' ,
5858 'button1 ' ,
5959], array_keys (iterator_to_array ($ list )));
60+ // again
61+ Assert::same ([
62+ 'one ' ,
63+ 'inner ' ,
64+ 'inner2 ' ,
65+ 'button2 ' ,
66+ 'two ' ,
67+ 'button1 ' ,
68+ ], array_keys (iterator_to_array ($ list )));
6069
6170
6271// Recursive & filter I
@@ -65,6 +74,11 @@ Assert::same([
6574 'button2 ' ,
6675 'button1 ' ,
6776], array_keys (iterator_to_array ($ list )));
77+ // again
78+ Assert::same ([
79+ 'button2 ' ,
80+ 'button1 ' ,
81+ ], array_keys (iterator_to_array ($ list )));
6882
6983
7084// Recursive & filter II
You can’t perform that action at this time.
0 commit comments