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()); } }