diff --git a/src/Plugin/Filtering/Builder/Reject.php b/src/Plugin/Filtering/Builder/Reject.php index 444ec7ec..11faa2a9 100644 --- a/src/Plugin/Filtering/Builder/Reject.php +++ b/src/Plugin/Filtering/Builder/Reject.php @@ -16,6 +16,7 @@ final class Reject implements StepBuilderInterface private ?Node\Expr $logger = null; private ?Node\Expr $rejection = null; private ?Node\Expr $state = null; + private ?Node\Expr $dataToFormat = null; /** @var list */ private array $exclusions = []; @@ -42,6 +43,13 @@ public function withState(Node\Expr $state): self return $this; } + public function withDataToFormat(Node\Expr $dataToFormat): self + { + $this->dataToFormat = $dataToFormat; + + return $this; + } + public function withExclusions(Node\Expr ...$exclusions): self { array_push($this->exclusions, ...$exclusions); @@ -142,7 +150,7 @@ class: new Node\Stmt\Class_(null, [ new Node\Expr\New_( new Node\Name\FullyQualified(AcceptanceResultBucket::class), [ - new Node\Arg(new Node\Expr\Variable('input')), + $this->dataToFormat !== null ? new Node\Arg($this->dataToFormat) : new Node\Arg(new Node\Expr\Variable('input')), ] ), ), diff --git a/src/Plugin/Filtering/Configuration/Reject.php b/src/Plugin/Filtering/Configuration/Reject.php index 1a426ce2..8752c147 100644 --- a/src/Plugin/Filtering/Configuration/Reject.php +++ b/src/Plugin/Filtering/Configuration/Reject.php @@ -28,6 +28,13 @@ public function getConfigTreeBuilder(): TreeBuilder ->then(asExpression()) ->end() ->end() + ->scalarNode('dataToFormat') + ->cannotBeEmpty() + ->validate() + ->ifTrue(isExpression()) + ->then(asExpression()) + ->end() + ->end() ->end() ->end() ; diff --git a/src/Plugin/Filtering/Factory/Reject.php b/src/Plugin/Filtering/Factory/Reject.php index 047a919f..f012dd9e 100644 --- a/src/Plugin/Filtering/Factory/Reject.php +++ b/src/Plugin/Filtering/Factory/Reject.php @@ -71,6 +71,9 @@ public function compile(array $config): Repository\Reject $builder->withExclusions( compileExpression($interpreter, $condition['when']) ); + if (array_key_exists('dataToFormat', $condition)) { + $builder->withDataToFormat($condition['dataToFormat']); + } } return $repository;