public function createRelationForProfileChild(EiProfil $profileParent, EiProfil $profile, Doctrine_Connection $conn = null) { if ($conn == null) { $conn = Doctrine_Manager::connection(); } $collection1 = $conn->getTable('EiProfilScenario')->findByProfileIdAndProfileRef($profileParent->getProfileId(), $profileParent->getProfileRef()); //Si des relations existent alors on les recrée pour le profil enfant if ($collection1->getFirst()) { $collection2 = new Doctrine_Collection('EiProfilScenario'); foreach ($collection1 as $profil_scenario) { $new_obj = new EiProfilScenario(); $new_obj->setProfileId($profile->getProfileId()); $new_obj->setProfileRef($profile->getProfileRef()); $new_obj->setEiScenarioId($profil_scenario->getEiScenarioId()); $new_obj->setEiVersionId($profil_scenario->getEiVersionId()); $collection2->add($new_obj); } if ($collection2->getFirst()) { $collection2->save($conn); } //Sauvegarde des nouvelles relations } }
public function createProfilScenarioForClone($copie, Doctrine_Connection $conn) { if ($conn == null) { $conn = Doctrine_Manager::connection(); } //Attribution des profils scenario à la première version trouvée if ($copie != null) { $clones_version = $conn->getTable('EiVersion')->findByEiScenarioId($copie->getId()); if (count($clones_version) > 0) { $first_clone_version = $clones_version->getFirst(); foreach ($this->getEiProjet()->getProfils() as $pf) { $profil_scenario = new EiProfilScenario(); $profil_scenario->setProfileId($pf->getProfileId()); $profil_scenario->setProfileRef($pf->getProfileRef()); $profil_scenario->setEiVersionId($first_clone_version->getId()); $profil_scenario->setEiScenarioId($copie->getId()); $profil_scenario->setCreatedAt($first_clone_version->getCreatedAt()); $profil_scenario->setUpdatedAt($first_clone_version->getUpdatedAt()); $profil_scenario->save($conn); } } } }
public function executeEditVersionWithoutId(sfWebRequest $request) { $this->checkProject($request); $this->checkProfile($request, $this->ei_project); $this->checkEiScenario($request, $this->ei_project); //On recherche une association version-profil pour le scénario $this->profil_scenario = Doctrine_Core::getTable("EiProfilScenario")->findOneByEiScenarioIdAndProfileIdAndProfileRef($this->ei_scenario->getId(), $this->ei_profile->getProfileId(), $this->ei_profile->getProfileRef()); /* Si le profil a été récemment ajouté sur script, alors il n'est affecté à aucune version , * du coup on affecte le profil à la première version rencontrée */ if ($this->profil_scenario == null) { $pf = Doctrine_Core::getTable("EiProfilScenario")->findByEiScenarioId($this->ei_scenario->getId())->getFirst(); $new_profil_scenario = new EiProfilScenario(); $new_profil_scenario->setEiScenarioId($this->ei_scenario->getId()); $new_profil_scenario->setProfileId($this->ei_profile->getProfileId()); $new_profil_scenario->setProfileRef($this->ei_profile->getProfileRef()); $new_profil_scenario->setEiVersionId($pf->getEiVersionId()); $new_profil_scenario->save(); $this->profil_scenario = $new_profil_scenario; } $this->forward404If(!$this->profil_scenario, 'System error : Environment must be associated to at least one version of test suit'); //On récupère la version $this->ei_version = Doctrine_Core::getTable("EiVersion")->findOneById($this->profil_scenario->getEiVersionId()); // On redirige ensuite l'utilisateur vers la version trouvée $projet_edit_eiversion = $this->urlParameters; $projet_edit_eiversion['ei_scenario_id'] = $this->ei_scenario->getId(); $projet_edit_eiversion['action'] = 'edit'; $projet_edit_eiversion['ei_version_id'] = $this->ei_version->getId(); $this->redirect($this->generateUrl('projet_edit_eiversion', $projet_edit_eiversion)); return sfView::NONE; }