Commit 8f3495ec authored by Jean-Philippe Metivier's avatar Jean-Philippe Metivier
Browse files

Ajustement pour la maj de la date de modification du formulaire

parent 9ef6ec2d
Loading
Loading
Loading
Loading
Loading
+32 −0
Original line number Diff line number Diff line
@@ -2,6 +2,7 @@

namespace UnicaenAutoform\Service\Categorie;

use DateTime;
use Doctrine\ORM\NonUniqueResultException;
use Doctrine\ORM\QueryBuilder;
use DoctrineModule\Persistence\ProvidesObjectManager;
@@ -22,12 +23,24 @@ class CategorieService
    {
        $this->getObjectManager()->persist($categorie);
        $this->getObjectManager()->flush($categorie);

        $formulaire = $categorie->getFormulaire();
        if ($formulaire) {
            $formulaire->setHistoModification(new DateTime());
            $this->getObjectManager()->flush($formulaire);
        }
        return $categorie;
    }

    public function update(Categorie $categorie): Categorie
    {
        $this->getObjectManager()->flush($categorie);

        $formulaire = $categorie->getFormulaire();
        if ($formulaire) {
            $formulaire->setHistoModification(new DateTime());
            $this->getObjectManager()->flush($formulaire);
        }
        return $categorie;
    }

@@ -35,6 +48,12 @@ class CategorieService
    {
        $categorie->historiser();
        $this->getObjectManager()->flush($categorie);

        $formulaire = $categorie->getFormulaire();
        if ($formulaire) {
            $formulaire->setHistoModification(new DateTime());
            $this->getObjectManager()->flush($formulaire);
        }
        return $categorie;
    }

@@ -42,6 +61,13 @@ class CategorieService
    {
        $categorie->dehistoriser();
        $this->getObjectManager()->flush($categorie);
        $formulaire = $categorie->getFormulaire();

        if ($formulaire) {
            $formulaire->setHistoModification(new DateTime());
            $this->getObjectManager()->flush($formulaire);
        }

        return $categorie;
    }

@@ -49,6 +75,12 @@ class CategorieService
    {
        $this->getObjectManager()->remove($categorie);
        $this->getObjectManager()->flush();

        $formulaire = $categorie->getFormulaire();
        if ($formulaire) {
            $formulaire->setHistoModification(new DateTime());
            $this->getObjectManager()->flush($formulaire);
        }
        return $categorie;
    }

+32 −0
Original line number Diff line number Diff line
@@ -2,6 +2,7 @@

namespace UnicaenAutoform\Service\Champ;

use DateTime;
use Doctrine\ORM\NonUniqueResultException;
use Doctrine\ORM\QueryBuilder;
use DoctrineModule\Persistence\ProvidesObjectManager;
@@ -20,12 +21,24 @@ class ChampService
    {
        $this->getObjectManager()->persist($champ);
        $this->getObjectManager()->flush($champ);

        $formulaire = $champ->getCategorie()?->getFormulaire();
        if ($formulaire) {
            $formulaire->setHistoModification(new DateTime());
            $this->getObjectManager()->flush($formulaire);
        }
        return $champ;
    }

    public function update(Champ $champ): Champ
    {
        $this->getObjectManager()->flush($champ);

        $formulaire = $champ->getCategorie()?->getFormulaire();
        if ($formulaire) {
            $formulaire->setHistoModification(new DateTime());
            $this->getObjectManager()->flush($formulaire);
        }
        return $champ;
    }

@@ -33,6 +46,12 @@ class ChampService
    {
        $champ->historiser();
        $this->getObjectManager()->flush($champ);

        $formulaire = $champ->getCategorie()?->getFormulaire();
        if ($formulaire) {
            $formulaire->setHistoModification(new DateTime());
            $this->getObjectManager()->flush($formulaire);
        }
        return $champ;
    }

@@ -40,6 +59,12 @@ class ChampService
    {
        $champ->dehistoriser();
        $this->getObjectManager()->flush($champ);

        $formulaire = $champ->getCategorie()?->getFormulaire();
        if ($formulaire) {
            $formulaire->setHistoModification(new DateTime());
            $this->getObjectManager()->flush($formulaire);
        }
        return $champ;
    }

@@ -51,6 +76,13 @@ class ChampService
    {
        $this->getObjectManager()->remove($champ);
        $this->getObjectManager()->flush();

        $formulaire = $champ->getCategorie()?->getFormulaire();
        if ($formulaire) {
            $formulaire->setHistoModification(new DateTime());
            $this->getObjectManager()->flush($formulaire);
        }

        return $champ;
    }