Commit bc1de908 authored by Antony Le Courtes's avatar Antony Le Courtes
Browse files

Correction bug horodatage du service prévisionnel lors de la création du contrat (#40925)

parent 07beaac8
......@@ -10,6 +10,7 @@ use Application\Entity\Db\Structure;
use Application\Entity\Db\TypeVolumeHoraire;
use Application\Entity\Db\Validation;
use Application\Entity\Db\VolumeHoraire;
use Application\ORM\Event\Listeners\HistoriqueListener;
use Application\Service\Traits\ContextServiceAwareTrait;
use Application\Service\Traits\ContratServiceAwareTrait;
use Application\Service\Traits\EtatVolumeHoraireServiceAwareTrait;
......@@ -37,7 +38,6 @@ class ContratProcessus extends AbstractProcessus
use ValidationServiceAwareTrait;
/**
* @param Intervenant $intervenant
* @param Contrat|null $contrat
......@@ -185,6 +185,7 @@ class ContratProcessus extends AbstractProcessus
foreach ($service->getVolumeHoraire() as $vh) {
/* @var $vh VolumeHoraire */
$vh->setContrat($contrat);
$this->desactivateHistoriqueListenerEvent();
$this->getEntityManager()->persist($vh);
}
}
......@@ -214,12 +215,12 @@ class ContratProcessus extends AbstractProcessus
$vhs = $sVH->getList($sVH->finderByContrat($contrat));
// détachement du contrat et des VH
$this->desactivateHistoriqueListenerEvent();
foreach ($vhs as $vh) {
/* @var $vh \Application\Entity\Db\VolumeHoraire */
$vh->setContrat(null);
$sVH->save($vh);
}
$this->getServiceContrat()->delete($contrat);
return $this;
......@@ -379,4 +380,19 @@ class ContratProcessus extends AbstractProcessus
return $fr->getServiceDu() + $fr->getSolde();
}
public function desactivateHistoriqueListenerEvent()
{
$eventManager = $this->getEntityManager()->getEventManager();
$allListeners = $eventManager->getListeners();
foreach ($allListeners as $event => $listeners) {
foreach ($listeners as $listener) {
if ($listener instanceof HistoriqueListener) {
$this->getEntityManager()->getEventManager()->removeEventListener(['prePersist', 'preUpdate'], $listener);
}
}
}
}
}
\ No newline at end of file
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment