/** * @param Application $application * @param UserInterface $user * @return CvEntity * @since 0.26 */ public function createFromApplication(Application $application, UserInterface $user) { $cv = $this->create(); $cv->setContact($application->getContact()); $assignedUser = $application->getJob()->getUser(); $cv->setUser($assignedUser); $perms = $cv->getPermissions(); $perms->inherit($application->getPermissions()); // grant view permission to the user that issued this creation. $perms->grant($user, PermissionsInterface::PERMISSION_VIEW); // revoke change permission to the original applicant $perms->revoke($application->getUser(), PermissionsInterface::PERMISSION_CHANGE); $applicationAttachments = $application->getAttachments(); if (count($applicationAttachments) > 0) { $cvAttachments = []; /* @var $applicationAttachment \Applications\Entity\Attachment */ foreach ($applicationAttachments as $applicationAttachment) { $file = new \Doctrine\MongoDB\GridFSFile(); $file->setBytes($applicationAttachment->getContent()); $cvAttachment = new \Cv\Entity\Attachment(); $cvAttachment->setName($applicationAttachment->getName()); $cvAttachment->setType($applicationAttachment->getType()); $cvAttachment->setUser($assignedUser); $cvAttachment->setFile($file); $cvAttachment->setDateUploaded($applicationAttachment->getDateUploaded()); $cvAttachments[] = $cvAttachment; } $cv->setAttachments(new \Doctrine\Common\Collections\ArrayCollection($cvAttachments)); } return $cv; }
public function copy(FileInterface $fileDocument) { $gFile = $fileDocument->file; $gridFS = new \Doctrine\MongoDB\GridFSFile(); $gridFS->setBytes($gFile->getBytes()); $entity = $this->create(); $entity->setFile($gridFS); $gridFS->getSize(); $entity->name = $fileDocument->name; $entity->type = $fileDocument->type; return $entity; }
public function oneClickApplyAction() { /* @var \Applications\Entity\Application $application */ $application = $this->container->getEntity(); $job = $application->getJob(); $atsMode = $job->getAtsMode(); // check for one click apply if (!($atsMode->isIntern() && $atsMode->getOneClickApply())) { // redirect to regular application return $this->redirect()->toRoute('lang/apply', ['applyId' => $job->getApplyId()]); } $network = $this->params('network'); $hybridAuth = $this->serviceLocator->get('HybridAuthAdapter')->getHybridAuth(); /* @var $authProfile \Hybrid_User_Profile */ $authProfile = $hybridAuth->authenticate($network)->getUserProfile(); /* @var \Auth\Entity\SocialProfiles\AbstractProfile $profile */ $profile = $this->plugin('Auth/SocialProfiles')->fetch($network); $contact = $application->getContact(); $contact->setEmail($authProfile->emailVerified ?: $authProfile->email); $contact->setFirstName($authProfile->firstName); $contact->setLastName($authProfile->lastName); $contact->setBirthDay($authProfile->birthDay); $contact->setBirthMonth($authProfile->birthMonth); $contact->setBirthYear($authProfile->birthYear); $contact->setPostalCode($authProfile->zip); $contact->setCity($authProfile->city); $contact->setStreet($authProfile->address); $contact->setPhone($authProfile->phone); $contact->setGender($authProfile->gender); $profiles = $application->getProfiles(); $profiles->add($profile); $cv = $application->getCv(); $cv->setEmployments($profile->getEmployments()); $cv->setEducations($profile->getEducations()); if ($authProfile->photoURL) { $response = (new \Zend\Http\Client($authProfile->photoURL, ['sslverifypeer' => false]))->send(); $file = new \Doctrine\MongoDB\GridFSFile(); $file->setBytes($response->getBody()); $image = new \Applications\Entity\Attachment(); $image->setName($contact->getLastName() . $contact->getFirstName()); $image->setType($response->getHeaders()->get('Content-Type')->getFieldValue()); $image->setFile($file); $image->setPermissions($application->getPermissions()); $contact->setImage($image); } $urlOptions = []; if ($this->params('immediately')) { $application->getAttributes()->setAcceptedPrivacyPolicy(true); $urlOptions = ['query' => ['do' => 'send']]; } return $this->redirect()->toRoute('lang/apply', ['applyId' => $job->getApplyId()], $urlOptions); }