Example #1
0
 /**
  * @param UploadedFile $file
  * @param BlogOptions  $options
  */
 public function updateBanner(UploadedFile $file = null, BlogOptions $options)
 {
     $ds = DIRECTORY_SEPARATOR;
     if (file_exists($this->uploadDir . $ds . $options->getBannerBackgroundImage()) || $file === null) {
         @unlink($this->uploadDir . $ds . $options->getBannerBackgroundImage());
     }
     if ($file) {
         $uniqid = uniqid();
         $options->setBannerBackgroundImage($uniqid);
         $file->move($this->uploadDir, $uniqid);
     } else {
         $options->setBannerBackgroundImage(null);
     }
     $this->objectManager->persist($options);
     $this->objectManager->flush();
 }