Commit 95cdbc05 authored by Jean-Philippe Metivier's avatar Jean-Philippe Metivier
Browse files

Merge branch 'Substitution'

parents 146f90e1 3353c4d6
Loading
Loading
Loading
Loading
+13 −3
Changes for module/Application/src/Application/Controller/SubstitutionController.php: 13 added lines, 3 removed lines.
Original line number Diff line number Diff line
@@ -206,12 +206,22 @@ class SubstitutionController extends AbstractController
            $dictionnaire[$identifiant][] = $structure;
        }

//        /** @var StructureConcreteInterface $structure */
//        $tmpres = [];
//        foreach ($dictionnaire as $key => $structures) {
//            foreach ($structures as $structure) {
//                $tmpres[$key][] = $structure->getId() . " " . $structure->getSourceCode();
//            }
//        }
//        var_dump($tmpres);

        $substitutions = [];
        foreach ($dictionnaire as $identifiant => $structures) {
            if (count($structures) >= 2) {
                $sources = [];
                $cible = null;

                /** @var StructureConcreteInterface $structure */
                foreach ($structures as $structure) {
                    $prefix = explode("::",$structure->getSourceCode())[0];
                    if ($prefix === "SyGAL" || $prefix === "COMUE") {
@@ -240,7 +250,7 @@ class SubstitutionController extends AbstractController
        /** @var StructureConcreteInterface $structure */
        foreach ($structures as $structure) {
            $prefix = explode("::", $structure->getSourceCode())[0];
            if ($prefix === "SyGAL") {
            if ($prefix === "SyGAL" || $prefix === "COMUE") {
                $cible = $structure;
            } else {
                $sources[] = $structure;
@@ -264,7 +274,7 @@ class SubstitutionController extends AbstractController
        /** @var StructureConcreteInterface $structure */
        foreach ($structures as $structure) {
            $prefix = explode("::",$structure->getSourceCode())[0];
            if ($prefix === "SyGAL") {
            if ($prefix === "SyGAL" || $prefix === "COMUE") {
                $cible = $structure;
            } else {
                $sources[] = $structure;
@@ -361,7 +371,7 @@ class SubstitutionController extends AbstractController
        /** @var StructureConcreteInterface $structure */
        foreach ($structures as $structure) {
            $prefix = explode("::",$structure->getSourceCode())[0];
            if ($prefix === "SyGAL") {
            if ($prefix === "SyGAL" || $prefix === "COMUE") {
                $cible = $structure;
            } else {
                $sources[] = $structure;
+13 −1
Changes for module/Application/src/Application/Service/Structure/StructureService.php: 13 added lines, 1 removed line.
Original line number Diff line number Diff line
@@ -90,9 +90,21 @@ class StructureService extends BaseService

        $structureCibleDataObject->setSourceCode($sourceCode);

        /** si toutes les sources ont le même sourcecode (au préfixe près) alors sourcecode => CODE_COMUE::source */
        $unique = explode(EtablissementPrefixFilter::ETAB_PREFIX_SEP, $structuresSources[0]->getSourceCode())[1];
        foreach ($structuresSources as $structureSource) {
            $code = explode(EtablissementPrefixFilter::ETAB_PREFIX_SEP, $structureSource->getSourceCode());
            if ($code[1] != $unique) {
                $unique = uniqid();
                break;
            }
        }
        var_dump(Etablissement::CODE_COMUE . EtablissementPrefixFilter::ETAB_PREFIX_SEP . $unique);

        // instanciation du couple (Etab|ED|UR ; Structure) cible
        $structureConcreteCible = Structure::constructFromDataObject($structureCibleDataObject, $typeStructure, $sourceSygal);
        $structureConcreteCible->setSourceCode(uniqid(Etablissement::CODE_COMUE . EtablissementPrefixFilter::ETAB_PREFIX_SEP));
        $structureConcreteCible->setSourceCode(Etablissement::CODE_COMUE . EtablissementPrefixFilter::ETAB_PREFIX_SEP . $unique);
        $structureConcreteCible->getStructure()->setSourceCode(Etablissement::CODE_COMUE . EtablissementPrefixFilter::ETAB_PREFIX_SEP . $unique);
//        $structureConcreteCible->getStructure()->setSourceCode(uniqid(Etablissement::CODE_COMUE . EtablissementPrefixFilter::ETAB_PREFIX_SEP));
        $structureConcreteCible->getStructure()->setCode("tmp");
        $structureRattachCible = $structureConcreteCible->getStructure(); // StructureSubstitution ne référence que des entités de type Structure