Commit 59b9cb0f authored by Bertrand Gauthier's avatar Bertrand Gauthier
Browse files

Abandon du paramètre SOURCE_CODE_ETAB_COMMUNAUTE pour fetcher l'établissement COMUE éventuel.

parent 4af4d884
Loading
Loading
Loading
Loading
+24 −0
Original line number Diff line number Diff line
@@ -43,6 +43,11 @@ class Etablissement implements StructureConcreteInterface, HistoriqueAwareInterf
     */
    protected $estAssocie = false;

    /**
     * @var bool
     */
    protected $estComue = false;

    /**
     * Etablissement constructor.
     */
@@ -194,6 +199,25 @@ class Etablissement implements StructureConcreteInterface, HistoriqueAwareInterf
        return $this;
    }

    /**
     * @return bool
     */
    public function estComue()
    {
        return $this->estComue;
    }

    /**
     * @param bool $estComue
     * @return Etablissement
     */
    public function setEstComue($estComue)
    {
        $this->estComue = $estComue;

        return $this;
    }

    /**
     * @return string
     */
+1 −0
Original line number Diff line number Diff line
@@ -12,6 +12,7 @@
        <field name="domaine"   type="string"   length="50"  column="DOMAINE"   nullable="true"/>
        <field name="estMembre"  type="boolean" column="EST_MEMBRE" nullable="false"/>
        <field name="estAssocie" type="boolean" column="EST_ASSOCIE" nullable="false"/>
        <field name="estComue" type="boolean" column="EST_COMUE"/>

        <one-to-many field="theses"         target-entity="Application\Entity\Db\These"     mapped-by="etablissement"/>
        <one-to-many field="doctorants"     target-entity="Application\Entity\Db\Doctorant" mapped-by="etablissement"/>
+0 −2
Original line number Diff line number Diff line
@@ -10,8 +10,6 @@ class Parametre
    // todo: cette valeur n'existe pas dans la table !
    const APP_UTILISATEUR_ID = 'APP_UTILISATEUR_ID';

    const ID__SOURCE_CODE_ETAB_COMMUNAUTE = 'SOURCE_CODE_ETAB_COMMUNAUTE';

    /**
     * @var string
     */
+11 −12
Original line number Diff line number Diff line
@@ -7,14 +7,13 @@ use Application\Entity\Db\Repository\EtablissementRepository;
use Application\Entity\Db\TypeStructure;
use Application\Entity\Db\Utilisateur;
use Application\Service\BaseService;
use Application\Service\Parametre\ParametreServiceAwareTrait;
use Application\SourceCodeStringHelperAwareTrait;
use Doctrine\ORM\NonUniqueResultException;
use Doctrine\ORM\OptimisticLockException;
use UnicaenApp\Exception\RuntimeException;

class EtablissementService extends BaseService
{
    use ParametreServiceAwareTrait;
    use SourceCodeStringHelperAwareTrait;

    /**
@@ -33,20 +32,20 @@ class EtablissementService extends BaseService
     *
     * @return Etablissement|null
     */
    public function fetchEtablissementCommunaute()
    public function fetchEtablissementComue()
    {
        $sourceCode = $this->parametreService->getSourceCodeEtablissementCommunaute();
        if ($sourceCode === null) {
            return null;
        }
        $qb = $this->getRepository()->createQueryBuilder('e')
            ->addSelect('s')
            ->join('e.structure', 's')
            ->where('e.estComue = 1');

        $etab = $this->getRepository()->findOneBySourceCode($sourceCode);
        if ($etab === null) {
            throw new RuntimeException(
                "Anomalie: aucun établissement trouvé avec le SOURCE_CODE '$sourceCode' spécifié pour l'établissement chapeau.");
        try {
            $comue = $qb->getQuery()->getOneOrNullResult();
        } catch (NonUniqueResultException $e) {
            throw new RuntimeException("Anomalie: plusieurs établissements COMUE trouvés.");
        }

        return $etab;
        return $comue;
    }

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

namespace Application\Service\Etablissement;

use Application\Service\Parametre\ParametreService;
use Application\SourceCodeStringHelper;
use Zend\ServiceManager\ServiceLocatorInterface;

@@ -16,13 +15,7 @@ class EtablissementServiceFactory
     */
    public function __invoke(ServiceLocatorInterface $serviceLocator)
    {
        /**
         * @var ParametreService $parametreService
         */
        $parametreService = $serviceLocator->get('ParametreService');

        $service = new EtablissementService();
        $service->setParametreService($parametreService);

        /**
         * @var SourceCodeStringHelper $sourceCodeHelper
Loading