Skip to content

Commit

Permalink
RatingComponent: pass given values in render() to template
Browse files Browse the repository at this point in the history
  • Loading branch information
MartkCz committed Sep 8, 2022
1 parent 9fa4a47 commit eb0e672
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions src/Rating/RatingComponent.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
namespace Utilitte\Components\Rating;

use Nette\Application\UI\Control;
use Nette\Security\User;
use Utilitte\Components\Rating\Model\RatingModelInterface;
use Utilitte\Components\Rating\ValueObject\Rating;
use Utilitte\Components\Utility\TControl;
Expand All @@ -23,7 +22,6 @@ final class RatingComponent extends Control
public function __construct(
private RatingModelInterface $model,
private Rating $rating,
private User $user,
)
{
}
Expand All @@ -40,7 +38,7 @@ public function onVoted(callable $callback): void
$this->onVoted[] = $callback;
}

public function render(): void
public function render(mixed ... $arguments): void
{
$template = $this->getTemplate();
$template->setFile($this->getFile(__DIR__ . '/templates/rating.latte'));
Expand All @@ -53,6 +51,10 @@ public function render(): void
$template->increase = $this->increase;
$template->canVote = $this->rating->canVote();

foreach ($arguments as $name => $value) {
$template->$name = $value;
}

$template->render();
}

Expand Down

0 comments on commit eb0e672

Please sign in to comment.