Loading src/UnicaenAutoform/Controller/FormulaireController.php +6 −2 Original line number Diff line number Diff line Loading @@ -143,6 +143,9 @@ class FormulaireController extends AbstractActionController $data = $request->getPost(); if ($data["reponse"] === "oui") { foreach ($instances as $instance) { foreach ($instance->getReponses() as $reponse) { $this->getFormulaireReponseService()->delete($reponse); } $this->getFormulaireInstanceService()->delete($instance); } $this->getFormulaireService()->delete($formulaire); Loading Loading @@ -581,16 +584,17 @@ class FormulaireController extends AbstractActionController $this->getCategorieService()->create($newCategorie); $duplicata->addCategorie($newCategorie); foreach ($newCategorie->getChamps() as $champ) { foreach ($categorie->getChamps() as $champ) { $newChamp = Champ::clone($champ, true, $newCategorie); $this->getChampService()->create($newChamp); $newCategorie->addChamp($newChamp); $this->getCategorieService()->update($newCategorie); } } $this->getFormulaireService()->update($duplicata); /** @see FormulaireController::modifierAction() */ return $this->redirect()->toRoute('autoform/formulaire/modifier',['formulaire' => $formulaire->getId()], [], true); return $this->redirect()->toRoute('autoform/formulaire/modifier',['formulaire' => $duplicata->getId()], [], true); } } No newline at end of file src/UnicaenAutoform/Entity/Db/Categorie.php +2 −1 Original line number Diff line number Diff line Loading @@ -2,6 +2,7 @@ namespace UnicaenAutoform\Entity\Db; use DateTime; use Doctrine\Common\Collections\ArrayCollection; use Doctrine\Common\Collections\Collection; use UnicaenAutoform\Entity\HasMotsClefsAwareTrait; Loading Loading @@ -29,7 +30,7 @@ class Categorie implements HistoriqueAwareInterface, HasMotsClefsInterface public static function clone(Categorie $categorie, bool $withHisto = true): Categorie { $clone = new Categorie(); $clone->setCode($categorie->getCode() . " DUPLICATA"); $clone->setCode($categorie->getCode() . " DUPLICATA " . (new DateTime())->getTimestamp()); $clone->setLibelle($categorie->getLibelle()); $clone->setOrdre($categorie->getOrdre()); $clone->setMotsClefs($categorie->getMotsClefs()); Loading src/UnicaenAutoform/Entity/Db/Champ.php +3 −2 Original line number Diff line number Diff line Loading @@ -2,6 +2,7 @@ namespace UnicaenAutoform\Entity\Db; use DateTime; use UnicaenAutoform\Entity\HasMotsClefsAwareTrait; use UnicaenAutoform\Entity\HasMotsClefsInterface; use UnicaenUtilisateur\Entity\Db\HistoriqueAwareInterface; Loading Loading @@ -48,9 +49,9 @@ class Champ implements HistoriqueAwareInterface, HasMotsClefsInterface { { $clone = new Champ(); if ($newCategorie !== null) $clone->setCategorie($newCategorie); $clone->setCode($champ->getCode() . " DUPLICATA"); $clone->setCode($champ->getCode() . " DUPLICATA ". (new DateTime())->getTimestamp()); $clone->setLibelle($champ->getLibelle()); $clone->setType($champ->getTexte()); $clone->setTexte($champ->getTexte()); $clone->setOrdre($champ->getOrdre()); $clone->setType($champ->getType()); $clone->setBalise($champ->getBalise()); Loading Loading
src/UnicaenAutoform/Controller/FormulaireController.php +6 −2 Original line number Diff line number Diff line Loading @@ -143,6 +143,9 @@ class FormulaireController extends AbstractActionController $data = $request->getPost(); if ($data["reponse"] === "oui") { foreach ($instances as $instance) { foreach ($instance->getReponses() as $reponse) { $this->getFormulaireReponseService()->delete($reponse); } $this->getFormulaireInstanceService()->delete($instance); } $this->getFormulaireService()->delete($formulaire); Loading Loading @@ -581,16 +584,17 @@ class FormulaireController extends AbstractActionController $this->getCategorieService()->create($newCategorie); $duplicata->addCategorie($newCategorie); foreach ($newCategorie->getChamps() as $champ) { foreach ($categorie->getChamps() as $champ) { $newChamp = Champ::clone($champ, true, $newCategorie); $this->getChampService()->create($newChamp); $newCategorie->addChamp($newChamp); $this->getCategorieService()->update($newCategorie); } } $this->getFormulaireService()->update($duplicata); /** @see FormulaireController::modifierAction() */ return $this->redirect()->toRoute('autoform/formulaire/modifier',['formulaire' => $formulaire->getId()], [], true); return $this->redirect()->toRoute('autoform/formulaire/modifier',['formulaire' => $duplicata->getId()], [], true); } } No newline at end of file
src/UnicaenAutoform/Entity/Db/Categorie.php +2 −1 Original line number Diff line number Diff line Loading @@ -2,6 +2,7 @@ namespace UnicaenAutoform\Entity\Db; use DateTime; use Doctrine\Common\Collections\ArrayCollection; use Doctrine\Common\Collections\Collection; use UnicaenAutoform\Entity\HasMotsClefsAwareTrait; Loading Loading @@ -29,7 +30,7 @@ class Categorie implements HistoriqueAwareInterface, HasMotsClefsInterface public static function clone(Categorie $categorie, bool $withHisto = true): Categorie { $clone = new Categorie(); $clone->setCode($categorie->getCode() . " DUPLICATA"); $clone->setCode($categorie->getCode() . " DUPLICATA " . (new DateTime())->getTimestamp()); $clone->setLibelle($categorie->getLibelle()); $clone->setOrdre($categorie->getOrdre()); $clone->setMotsClefs($categorie->getMotsClefs()); Loading
src/UnicaenAutoform/Entity/Db/Champ.php +3 −2 Original line number Diff line number Diff line Loading @@ -2,6 +2,7 @@ namespace UnicaenAutoform\Entity\Db; use DateTime; use UnicaenAutoform\Entity\HasMotsClefsAwareTrait; use UnicaenAutoform\Entity\HasMotsClefsInterface; use UnicaenUtilisateur\Entity\Db\HistoriqueAwareInterface; Loading Loading @@ -48,9 +49,9 @@ class Champ implements HistoriqueAwareInterface, HasMotsClefsInterface { { $clone = new Champ(); if ($newCategorie !== null) $clone->setCategorie($newCategorie); $clone->setCode($champ->getCode() . " DUPLICATA"); $clone->setCode($champ->getCode() . " DUPLICATA ". (new DateTime())->getTimestamp()); $clone->setLibelle($champ->getLibelle()); $clone->setType($champ->getTexte()); $clone->setTexte($champ->getTexte()); $clone->setOrdre($champ->getOrdre()); $clone->setType($champ->getType()); $clone->setBalise($champ->getBalise()); Loading