public function handleSelect($id) { /** @var GamePicture $picture */ $picture = $this->pictures->find($id); if (!$picture) { $this->flashMessage("Obrázek {$id} nebyl nalezen"); $this->redirect('default'); } $game = $picture->game; $game->primary_picture = $picture; $this->games->save($game); $this->flashMessage("Primární obrázek hry {$game->name} byl nasaven."); $this->redirect('default'); }
public function createComponentEditGameForm() { $form = $this->editGameFormFactory->create(); $form->onSave[] = function (Form $form, Game $game, GamePicture $picture = null, $tags = []) { if ($picture) { $game->primary_picture = $picture; $game->pictures->add($picture); $this->pictures->save($picture, false); } $game->completion_tags->clear(); /** @var Tag $tag */ foreach ($tags as $tag) { $game->completion_tags->add($tag); } $this->games->save($game); $this->flashMessage("Hra {$game->name} byla úspěšně přidána."); $this->redirect('default'); }; return $form; }