/** * Upload Profile Photo and update Profile * * @param Profile $profile * @param File $file * @param string $contentType */ protected function uploadProfilePhoto(Profile $profile, File $file, $contentType) { // Upload the photo to S3 $fileUrl = $this->get('service_photo_upload')->uploadPhoto($file, $contentType); // Update the Profile Photo $profile->setPhoto($fileUrl); $profile->setPhotoUploading(false); // Flush to DB $this->getDoctrine()->getManager()->flush($profile); }