Skip to content

Commit c2412b2

Browse files
committed
RatingComponent: add options
1 parent eb0e672 commit c2412b2

File tree

2 files changed

+12
-1
lines changed

2 files changed

+12
-1
lines changed

src/Rating/RatingComponent.php

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,13 @@ final class RatingComponent extends Control
1919

2020
private int $increase = 0;
2121

22+
/**
23+
* @param array<string, mixed> $options
24+
*/
2225
public function __construct(
2326
private RatingModelInterface $model,
2427
private Rating $rating,
28+
private array $options = [],
2529
)
2630
{
2731
}
@@ -51,6 +55,10 @@ public function render(mixed ... $arguments): void
5155
$template->increase = $this->increase;
5256
$template->canVote = $this->rating->canVote();
5357

58+
foreach ($this->options as $name => $value) {
59+
$template->$name = $value;
60+
}
61+
5462
foreach ($arguments as $name => $value) {
5563
$template->$name = $value;
5664
}

src/Rating/RatingComponentFactory.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,9 @@
88
interface RatingComponentFactory
99
{
1010

11-
public function create(RatingModelInterface $model, Rating $rating): RatingComponent;
11+
/**
12+
* @param array<string, mixed> $options
13+
*/
14+
public function create(RatingModelInterface $model, Rating $rating, array $options = []): RatingComponent;
1215

1316
}

0 commit comments

Comments
 (0)