Commit 3cb36cee authored by Antony Le Courtes's avatar Antony Le Courtes
Browse files

Ajout d'un try catch préventif pour éviter une exception sur la saisie de...

Ajout d'un try catch préventif pour éviter une exception sur la saisie de service référentiel dans le cas où une fonction référentiel est accrochée à une structure historisée. (#38250)
parent 27c0d114
Loading
Loading
Loading
Loading
+9 −4
Original line number Diff line number Diff line
@@ -3,6 +3,7 @@
namespace Application\Entity\Db;

use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\ORM\EntityNotFoundException;
use UnicaenApp\Entity\HistoriqueAwareInterface;
use UnicaenApp\Entity\HistoriqueAwareTrait;

@@ -385,10 +386,14 @@ class FonctionReferentiel implements HistoriqueAwareInterface
    public function __toString()
    {
        $str = $this->getLibelleCourt();

        //Try catch préventif dans le cas d'une fonction référentiel attachée à une structure historisée.
        try {
            if ($this->getStructure()) {
                $str .= " (" . $this->getStructure() . ")";
            }
        } catch (EntityNotFoundException $e) {
            return $str;
        }

        return $str;
    }