/**
  * Function finalizing processes
  * @param Project $project
  * @param Demand $demand
  * @param bool $flashbag
  * @return mixed
  */
 protected function processProjectCreationFinalize(Project $project, Demand $demand, $flashbag = true)
 {
     $returnValues['slot_name'] = 'proc';
     try {
         // Finalizing process
         //            if ($project->getGitLabProjectId() != null && $project->getRedmineProjectId() != null) {
         // Update demand
         $resolvedStatus = $this->em->getRepository('SpiritDevDBoxPortalBundle:Status')->findOneBy(array('canonicalName' => 'resolved'));
         $demand->setStatus($resolvedStatus);
         $project->setActive(true);
         // Apply project and demand modification
         $this->em->flush();
         // Send user mail + team mail
         $this->mailer->processProjectCreationSendMail($project);
         $returnValues['data'][] = $this->setRetVal('Mail sent', 'bool', true);
         if ($flashbag) {
             $this->session->getFlashBag()->set('success', 'flashbag.demand.processing_project.success');
         }
     } catch (\Exception $e) {
         $returnValues['data'][] = $this->setRetVal('Mail sent', 'bool', false);
     }
     $returnValues['data'][] = $this->setRetVal('Demand status', 'string', $demand->getStatus()->getCanonicalName());
     return $returnValues;
 }
 /**
  * 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;
 }