File tree 3 files changed +19
-1
lines changed
3 files changed +19
-1
lines changed Original file line number Diff line number Diff line change @@ -16,6 +16,7 @@ final class Reject implements StepBuilderInterface
16
16
private ?Node \Expr $ logger = null ;
17
17
private ?Node \Expr $ rejection = null ;
18
18
private ?Node \Expr $ state = null ;
19
+ private ?Node \Expr $ dataToFormat = null ;
19
20
/** @var list<?Node\Expr> */
20
21
private array $ exclusions = [];
21
22
@@ -42,6 +43,13 @@ public function withState(Node\Expr $state): self
42
43
return $ this ;
43
44
}
44
45
46
+ public function withDataToFormat (Node \Expr $ dataToFormat ): self
47
+ {
48
+ $ this ->dataToFormat = $ dataToFormat ;
49
+
50
+ return $ this ;
51
+ }
52
+
45
53
public function withExclusions (Node \Expr ...$ exclusions ): self
46
54
{
47
55
array_push ($ this ->exclusions , ...$ exclusions );
@@ -125,7 +133,7 @@ class: new Node\Stmt\Class_(null, [
125
133
new Node \Expr \New_ (
126
134
new Node \Name \FullyQualified (RejectionResultBucket::class),
127
135
[
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 ' ))
129
137
]
130
138
),
131
139
),
Original file line number Diff line number Diff line change @@ -28,6 +28,13 @@ public function getConfigTreeBuilder(): TreeBuilder
28
28
->then (asExpression ())
29
29
->end ()
30
30
->end ()
31
+ ->scalarNode ('dataToFormat ' )
32
+ ->cannotBeEmpty ()
33
+ ->validate ()
34
+ ->ifTrue (isExpression ())
35
+ ->then (asExpression ())
36
+ ->end ()
37
+ ->end ()
31
38
->end ()
32
39
->end ()
33
40
;
Original file line number Diff line number Diff line change @@ -71,6 +71,9 @@ public function compile(array $config): Repository\Reject
71
71
$ builder ->withExclusions (
72
72
compileExpression ($ interpreter , $ condition ['when ' ])
73
73
);
74
+ if (array_key_exists ('dataToFormat ' , $ condition )) {
75
+ $ builder ->withDataToFormat (compileExpression ($ interpreter , $ condition ['dataToFormat ' ]));
76
+ }
74
77
}
75
78
76
79
return $ repository ;
You can’t perform that action at this time.
0 commit comments