/**
  * 
  * @param Registration $registration
  * @param type $statusType
  * @param DateTime $timestamp
  * @throws InvalidArgumentException
  */
 protected function updateRegistrationStatus(Registration $registration, $statusType, DateTime $timestamp = null)
 {
     if (!RecruitmentStatus::statusTypeExists($statusType)) {
         throw new InvalidArgumentException('Situação inválida');
     }
     if ($timestamp === null) {
         $timestamp = new DateTime('now');
     }
     $em = $this->getEntityManager();
     $recStatus = $em->getRepository('Recruitment\\Entity\\RecruitmentStatus')->findOneBy(array('statusType' => $statusType));
     if ($recStatus !== null) {
         /**
          * retira o status anterior isCurrent = false
          */
         if ($registration->getRegistrationId() !== null) {
             $registration->getCurrentRegistrationStatus()->setIsCurrent(false);
         }
         // cria um status
         $regStatus = new RegistrationStatus();
         // associa o tipo e a data
         $regStatus->setRecruitmentStatus($recStatus)->setTimestamp($timestamp);
         // associa o status à inscrição
         $registration->addRegistrationStatus($regStatus);
     }
 }
示例#2
0
 protected function adjustPerson(Registration $registration)
 {
     $em = $this->getEntityManager();
     $newPerson = $registration->getPerson();
     $person = $em->getRepository('Recruitment\\Entity\\Person')->findOneBy(array('personCpf' => $newPerson->getPersonCpf()));
     // Se a pessoa já possui cadastro atualiza alguns dos dados
     if ($person !== null) {
         $person->setPersonPhone($newPerson->getPersonPhone());
         $person->setPersonEmail($newPerson->getPersonEmail());
         $person->setPersonSocialMedia($newPerson->getPersonSocialMedia());
         $person->setPersonRg($newPerson->getPersonRg());
         $this->adjustAddresses($newPerson);
         $person->addAddresses($newPerson->getAddresses());
         $newPerson->removeAddresses($newPerson->getAddresses());
         $registration->setPerson($person);
     } else {
         $this->adjustAddresses($newPerson);
         //imagem padrão do perfil
         $newPerson->setPersonPhoto();
     }
 }