private function createPicture(FileUpload $upload)
 {
     $path = $this->imageManager->put($upload);
     if ($path) {
         $picture = new PlatformPicture();
         $picture->path = $path;
         $picture->platform = $this->platform;
         return $picture;
     }
     return null;
 }
Example #2
0
 public function processForm(Form $form, $values)
 {
     $game = $this->games->find($values['id_game']);
     if (!$game) {
         $form['id_game']->addError("Hra nebyla nalezena");
         return;
     }
     $pictures = [];
     /** @var FileUpload $upload */
     foreach ($values['pictures'] as $upload) {
         $path = $this->imageManager->put($upload);
         if (!$path) {
             $form->addError("Obrázek {$upload->name} se nepodařilo nahrát");
             continue;
         }
         $picture = new Picture();
         $picture->path = $path;
         $picture->game = $game;
         $pictures[] = $picture;
     }
     $this->onSave($form, $pictures, $game);
 }