File tree Expand file tree Collapse file tree
Classes/NodeRendering/Extensibility/DocumentEnumerators Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1313class LimitEnumerator implements DocumentEnumeratorInterface
1414{
1515 protected int $ i = 0 ;
16- private int $ limit ;
16+ private ?int $ limit = null ;
17+ private ?string $ uriPathSegmentFilter = null ;
1718
1819 public function __construct (
1920 array $ options = []
2021 ) {
21- $ this ->limit = $ options ['limit ' ] ?? throw new \InvalidArgumentException ('Missing limit option ' );
22+ $ this ->limit = $ options ['limit ' ] ?? null ;
23+ $ this ->uriPathSegmentFilter = $ options ['uriPathSegmentFilter ' ] ?? null ;
2224 }
2325 public function enumerateDocumentNode (NodeInterface $ documentNode ): iterable
2426 {
25- if ($ this ->i ++ >= $ this ->limit ) {
26- return [];
27+ if ($ this ->uriPathSegmentFilter !== null ) {
28+ if (str_contains ($ documentNode ->getProperty ('uriPathSegment ' ), $ this ->uriPathSegmentFilter ) === false ) {
29+ return [];
30+ }
31+ }
32+
33+ // NOTE: Limiting must come LAST, after all other constraints have been evaluated (because we want
34+ // only filtered nodes from the other conditions to be counted against the limit)
35+ if ($ this ->limit !== null ) {
36+ if ($ this ->i ++ >= $ this ->limit ) {
37+ return [];
38+ }
2739 }
2840
2941 return [
Original file line number Diff line number Diff line change @@ -57,6 +57,7 @@ Flowpack:
5757 enumeratorClassName : Flowpack\DecoupledContentStore\NodeRendering\Extensibility\DocumentEnumerators\DefaultEnumerator
5858 # enumeratorClassName: Flowpack\DecoupledContentStore\NodeRendering\Extensibility\DocumentEnumerators\LimitEnumerator
5959 # enumeratorOptions:
60+ # uriPathSegmentFilter: vanucci-collection
6061 # limit: 20
6162 rendererClassName : Flowpack\DecoupledContentStore\NodeRendering\Extensibility\DocumentRenderers\FusionHtmlRenderer
6263
You can’t perform that action at this time.
0 commit comments