Skip to content
Open
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 $serialize_rejection = 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 withSerialiazeRejection(Node\Expr $serialize_rejection): self
{
$this->serialize_rejection = $serialize_rejection;

return $this;
}

public function withExclusions(Node\Expr ...$exclusions): self
{
array_push($this->exclusions, ...$exclusions);
Expand Down Expand Up @@ -125,7 +133,7 @@ class: new Node\Stmt\Class_(null, [
new Node\Expr\New_(
new Node\Name\FullyQualified(RejectionResultBucket::class),
[
new Node\Arg(new Node\Expr\Variable('input')),
$this->serialize_rejection !== null ? new Node\Arg($this->serialize_rejection) : 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('serialize_rejection')
->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('serialize_rejection', $condition)) {
$builder->withSerialiazeRejection(compileExpression($interpreter, $condition['serialize_rejection']));
}
}

return $repository;
Expand Down