Beispiel #1
0
 private function articlePictureHandle(Article $incoming, Article $database)
 {
     if ($incoming->getPicture() == '') {
         $incoming->setPicture($database->getPicture());
     } else {
         $oldImageStorage = $database->getPicture();
         $this->imageService->removeResource($oldImageStorage);
         $identifier = $this->imageService->storeNetteFile($incoming->getPicture());
         $incoming->setPicture($identifier);
     }
 }
Beispiel #2
0
 public function changeWebProfile(User $u)
 {
     try {
         $wp = $u->getWebProfile();
         $user = $this->userDao->find($u->getId());
         if ($wp->getPicture() instanceof \Nette\Http\FileUpload && $wp->getPicture()->isOk()) {
             $oldImgId = $wp->provideOldImgId();
             $this->imageService->removeResource($oldImgId);
             $identifier = $this->imageService->storeNetteFile($wp->getPicture());
             $wp->setPicture($identifier);
         }
         $this->entityManager->flush();
     } catch (\Exception $ex) {
         $this->logError($ex->getMessage());
         throw new Exceptions\DataErrorException($ex->getMessage(), $ex->getCode(), $ex->getPrevious());
     }
 }