Skip to content

Commit a198cfd

Browse files
committed
TASK: Add nodePathSegmentFilter to LimitEnumerator
1 parent 2894f16 commit a198cfd

File tree

1 file changed

+14
-4
lines changed

1 file changed

+14
-4
lines changed

Classes/NodeRendering/Extensibility/DocumentEnumerators/LimitEnumerator.php

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,19 +15,29 @@ class LimitEnumerator implements DocumentEnumeratorInterface
1515
protected int $i = 0;
1616
private ?int $limit = null;
1717
private ?string $uriPathSegmentFilter = null;
18+
private ?string $nodePathSegmentFilter = null;
1819

1920
public function __construct(
2021
array $options = []
2122
) {
2223
$this->limit = $options['limit'] ?? null;
2324
$this->uriPathSegmentFilter = $options['uriPathSegmentFilter'] ?? null;
25+
$this->nodePathSegmentFilter = $options['nodePathSegmentFilter'] ?? null;
2426
}
2527
public function enumerateDocumentNode(NodeInterface $documentNode): iterable
2628
{
27-
if ($this->uriPathSegmentFilter !== null) {
28-
if (str_contains($documentNode->getProperty('uriPathSegment'), $this->uriPathSegmentFilter) === false) {
29-
return [];
30-
}
29+
if (
30+
$this->uriPathSegmentFilter !== null
31+
&& str_contains($documentNode->getProperty('uriPathSegment'), $this->uriPathSegmentFilter) === false
32+
) {
33+
return [];
34+
}
35+
36+
if (
37+
$this->nodePathSegmentFilter !== null
38+
&& str_contains($documentNode->getPath(), $this->nodePathSegmentFilter) === false
39+
) {
40+
return [];
3141
}
3242

3343
// NOTE: Limiting must come LAST, after all other constraints have been evaluated (because we want

0 commit comments

Comments
 (0)