Example #1
0
 /**
  * Processing demand DBupdate
  * @param Demand $demandToProcess
  * @param User $dbUser
  * @param array $gitLabUser
  * @param \SimpleXMLElement $redmineUser
  * @return Demand
  */
 protected function processDemandUpdate(Demand $demandToProcess, User $dbUser, array $gitLabUser, \SimpleXMLElement $redmineUser)
 {
     // Getting EM and object
     $succeedStatus = $this->em->getRepository('SpiritDevDBoxPortalBundle:Status')->findOneBy(array('canonicalName' => 'resolved'));
     // Updating demand
     $demandToProcess->setStatus($succeedStatus);
     // Applying new apllicant
     $demandToProcess->setApplicant($dbUser);
     // Updating demand date depending on status
     if ($succeedStatus->getCanonicalName() == "resolved") {
         $demandToProcess->setResolutionDate(new \DateTime());
     } else {
         $demandToProcess->setResolutionDate(null);
     }
     // Updating user
     $dbUser->setGitLabId($gitLabUser['id']);
     $dbUser->setRedmineId($redmineUser->{'id'});
     // TODO Update QA if available
     // TODO Update CI if available
     // Registering update
     $this->em->flush();
     return $demandToProcess;
 }
 /**
  * Process demand registration
  * @return Demand
  */
 private function registerDemand()
 {
     // Managing EM entities
     $status = $this->em->getRepository('SpiritDevDBoxPortalBundle:Status')->findOneBy(array('canonicalName' => 'new'));
     $type = $this->em->getRepository('SpiritDevDBoxPortalBundle:Type')->findOneBy(array('canonicalName' => 'new_security'));
     // Creating empty demand
     $demand = new Demand();
     // Setting datas
     $demand->setAskdate(new \DateTime());
     $demand->setApplicant($this->getCurrentUser());
     $demand->setStatus($status);
     $demand->setType($type);
     $demand->setContent($this->setContentData());
     // Persisting EM entity
     $this->em->persist($demand);
     $this->em->flush();
     return $demand;
 }