protected function saveBlock(Block $formBlock, $timetable)
 {
     if (empty($this->block)) {
         $this->block = new Block();
         $this->block->setTitle($formBlock->getTitle());
         $this->block->setContent($formBlock->getContent());
         $this->block->setTypeId($formBlock->getTypeId());
         $this->block->setDomId($formBlock->getDomId());
     }
     // we need to init the relations even if the block is already filled with the post values
     // because stop_point_id in post contains the navitiaId value and doctrine expects a bdd ID
     // Plus, init Relations updates modified dates of line entity or stopPoint
     $this->initRelation($formBlock, $timetable);
     $this->om->persist($this->block);
     $this->om->flush();
 }
 public function process(Block $formBlock, $timetable)
 {
     $file = $formBlock->getContent();
     // convert into png if a jpeg was given
     if ($file->getMimeType() == ImgType::MIME_IMAGETYPE_JPEG) {
         $input = imagecreatefromjpeg($file->getRealPath());
         list($width, $height) = getimagesize($file->getRealPath());
         $output = imagecreatetruecolor($width, $height);
         imagecopy($output, $input, 0, 0, 0, 0, $width, $height);
         imagepng($output, $file->getRealPath() . '.png');
         imagedestroy($output);
         imagedestroy($input);
         $pngFile = new File($file->getRealPath() . '.png');
         $media = $this->mediaManager->saveByTimetable($timetable, $pngFile, $this->block->getDomId());
     } else {
         $media = $this->mediaManager->saveByTimetable($timetable, $file, $this->block->getDomId());
     }
     // TODO: saved with domain, we should store without it. Waiting for mediaDataCollector to be updated
     $formBlock->setContent($this->mediaManager->getUrlByMedia($media) . '?' . time());
     $this->saveBlock($formBlock, $timetable);
 }