Skip to content

Commit

Permalink
Add dataToFormat reject key management
Browse files Browse the repository at this point in the history
  • Loading branch information
JoMessina committed Oct 17, 2023
1 parent 247b399 commit f53fe4b
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 1 deletion.
10 changes: 9 additions & 1 deletion src/Plugin/Filtering/Builder/Reject.php
Original file line number Diff line number Diff line change
Expand Up @@ -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<?Node\Expr> */
private array $exclusions = [];

Expand All @@ -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);
Expand Down Expand Up @@ -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')),
]
),
),
Expand Down
7 changes: 7 additions & 0 deletions src/Plugin/Filtering/Configuration/Reject.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,13 @@ public function getConfigTreeBuilder(): TreeBuilder
->then(asExpression())
->end()
->end()
->scalarNode('dataToFormat')
->cannotBeEmpty()
->validate()
->ifTrue(isExpression())
->then(asExpression())
->end()
->end()
->end()
->end()
;
Expand Down
3 changes: 3 additions & 0 deletions src/Plugin/Filtering/Factory/Reject.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit f53fe4b

Please sign in to comment.