Skip to content

Commit 63a31b9

Browse files
committed
Add dataToFormat reject key management
1 parent 247b399 commit 63a31b9

File tree

3 files changed

+19
-1
lines changed

3 files changed

+19
-1
lines changed

src/Plugin/Filtering/Builder/Reject.php

+9-1
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ final class Reject implements StepBuilderInterface
1616
private ?Node\Expr $logger = null;
1717
private ?Node\Expr $rejection = null;
1818
private ?Node\Expr $state = null;
19+
private ?Node\Expr $dataToFormat = null;
1920
/** @var list<?Node\Expr> */
2021
private array $exclusions = [];
2122

@@ -42,6 +43,13 @@ public function withState(Node\Expr $state): self
4243
return $this;
4344
}
4445

46+
public function withDataToFormat(Node\Expr $dataToFormat): self
47+
{
48+
$this->dataToFormat = $dataToFormat;
49+
50+
return $this;
51+
}
52+
4553
public function withExclusions(Node\Expr ...$exclusions): self
4654
{
4755
array_push($this->exclusions, ...$exclusions);
@@ -125,7 +133,7 @@ class: new Node\Stmt\Class_(null, [
125133
new Node\Expr\New_(
126134
new Node\Name\FullyQualified(RejectionResultBucket::class),
127135
[
128-
new Node\Arg(new Node\Expr\Variable('input')),
136+
$this->dataToFormat !== null ? new Node\Arg($this->dataToFormat) : new Node\Arg(new Node\Expr\Variable('input'))
129137
]
130138
),
131139
),

src/Plugin/Filtering/Configuration/Reject.php

+7
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,13 @@ public function getConfigTreeBuilder(): TreeBuilder
2828
->then(asExpression())
2929
->end()
3030
->end()
31+
->scalarNode('dataToFormat')
32+
->cannotBeEmpty()
33+
->validate()
34+
->ifTrue(isExpression())
35+
->then(asExpression())
36+
->end()
37+
->end()
3138
->end()
3239
->end()
3340
;

src/Plugin/Filtering/Factory/Reject.php

+3
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,9 @@ public function compile(array $config): Repository\Reject
7171
$builder->withExclusions(
7272
compileExpression($interpreter, $condition['when'])
7373
);
74+
if (array_key_exists('dataToFormat', $condition)) {
75+
$builder->withDataToFormat(compileExpression($interpreter, $condition['dataToFormat']));
76+
}
7477
}
7578

7679
return $repository;

0 commit comments

Comments
 (0)