public function createComponentAddPictureForm()
 {
     $form = $this->addPictureFormFactory->create();
     $form->onSave[] = function ($form, $pictures, Game $game) {
         /** @var Picture $picture */
         foreach ($pictures as $picture) {
             $this->pictures->save($picture, false);
         }
         $this->pictures->flush();
         $this->flashMessage("Bylo přidáno " . sizeof($pictures) . " obrázků ke hře {$game->name}");
         $this->redirect('default');
     };
     return $form;
 }
 public function createComponentEditPlatformForm()
 {
     $form = $this->editPlatformFormFactory->create();
     $form->onSave[] = function (Form $form, Platform $platform, PlatformPicture $picture = null) {
         if ($picture) {
             $this->pictures->save($picture);
             if ($platform->picture) {
                 $this->pictures->delete($platform->picture);
                 $this->imageManager->delete($platform->picture);
             }
             $platform->picture = $picture;
         }
         $this->platforms->save($platform);
         $this->flashMessage('Platforma ' . $platform->title . ' byla uložena.');
         $this->redirect('default');
     };
     return $form;
 }
Example #3
0
 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;
 }