/** * Process Entity arranges * @param Project $project * @param bool $remove * @return mixed */ protected function processProjectDeletionFinalize(Project $project, $remove = true) { $returnValues['slot_name'] = 'proc'; try { // Finalizing process if (!$remove) { // Unset Local DB VCS related datas $project->setGitLabProjectId(null); $project->setGitLabHttpUrlToRepo(null); $project->setGitLabSshUrlToRepo(null); $project->setGitLabWebUrl(null); $project->setGitLabNamespace(null); $project->setGitNbCommits(null); $project->setGitCommitLastUpdate(null); // Unset Local DB PM related datas $project->setRedmineProjectId(null); $project->setRedmineProjectIdentifier(null); $project->setRedmineWebUrl(null); // Unser local DB QA related datas $project->setSonarProjectId(null); $project->setSonarProjectKey(null); $project->setSonarProjectUrl(null); // Other $project->setActive(false); // Remove project CIs $cis = $this->em->getRepository('SpiritDevDBoxPortalBundle:ContinuousIntegration')->findBy(array('project' => $project)); foreach ($cis as $ci) { $this->em->remove($ci); } } else { // Removing project $this->em->remove($project); } // Updating datas $this->em->flush(); $returnValues['data'][] = $this->setRetVal('Entity updated', 'bool', true); // Send user mail + team mail ? $this->mailer->processProjectDeletionSendMail($project); $returnValues['data'][] = $this->setRetVal('Mail sent', 'bool', true); $this->session->getFlashBag()->set('success', 'flashbag.demand.processing_deletion_project.success'); } catch (\Exception $e) { $returnValues['data'][] = $this->setRetVal('Entity updated', 'bool', false); // $returnValues['data'][] = $this->setRetVal('Mail sent', 'bool', false); $this->session->getFlashBag()->set('error', 'flashbag.demand.processing_deletion_project.error'); } return $returnValues; }