Commit 582568f0 authored by Thomas Hamel's avatar Thomas Hamel
Browse files

Affichage des formations externes sur le portfolio

parent 48085134
Loading
Loading
Loading
Loading
+7 −3
Original line number Diff line number Diff line
@@ -66,11 +66,14 @@ class FormationExterneAssertion extends AbstractAssertion implements AssertionI
            case 'restaurer' :
            case 'supprimer-attestation' :
            case 'telecharger-attestation' :
                if ($formationExterne instanceof FormationExterne) {
                    return $this->scopeValide($formationExterne);
                }
            case 'valider-formation-externe' :
            case 'refuser-formation-externe' :
            case 'revoquer-formation-externe' :
                if ($formationExterne) {
                    return $this->scopeValide($formationExterne);
                if ($formationExterne instanceof FormationExterne) {
                    return $formationExterne->estNonHistorise() && $this->scopeValide($formationExterne);
                }
        }
        return true;
@@ -94,8 +97,9 @@ class FormationExterneAssertion extends AbstractAssertion implements AssertionI
                if($role->isDoctorant() &&
                            $formationExterne->getValidation(TypeValidation::CODE_VALIDATION_FORMATION_EXTERNE)) return false;
            case FormationPrivileges::FORMATION_FORMATIONEXTERNE_TELECHARGER_ATTESTATION :
            case FormationPrivileges::FORMATION_FORMATIONEXTERNE_GERER_VALIDATION :
                return $this->scopeValide($formationExterne);
            case FormationPrivileges::FORMATION_FORMATIONEXTERNE_GERER_VALIDATION :
                return $formationExterne->estNonHistorise() && $this->scopeValide($formationExterne);
        }

        return true;
+1 −1
Original line number Diff line number Diff line
@@ -103,7 +103,7 @@ class FormationController extends AbstractController
                    $this->fichierService->saveFichiers($fichiers);
                    $formation->setFiche(array_pop($fichiers));
                }
                $this->getFormationService()->create($formation);
                $this->getFormationService()->create($formation, $form->get('competences')->getValue());
            }
        }

+1 −1
Original line number Diff line number Diff line
@@ -71,7 +71,7 @@ class FormationExterneController extends AbstractController
                    $this->fichierService->saveFichiers($fichiers);
                    $formationExterne->setAttestation(array_pop($fichiers));
                }
                $this->formationExterneService->create($formationExterne);
                $this->formationExterneService->create($formationExterne, $form->get('competences')->getValue());
            }
        }

+5 −1
Original line number Diff line number Diff line
@@ -26,7 +26,11 @@
            <join-column name="attestation_id" referenced-column-name="id" on-delete="CASCADE" nullable="false" unique="true"/>
        </one-to-one>

        <one-to-many field="validations" target-entity="Validation\Entity\Db\ValidationFormationExterne" mapped-by="formationExterne"/>
        <one-to-many field="validations" target-entity="Validation\Entity\Db\ValidationFormationExterne" mapped-by="formationExterne">
            <cascade>
                <cascade-remove/>
            </cascade>
        </one-to-many>

        <!-- HISTORISATION ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -->
        <field name="histoCreation" type="datetime" column="histo_creation" nullable="false"/>
+26 −25
Original line number Diff line number Diff line
@@ -53,15 +53,16 @@ class FormationExterneHydrator extends DoctrineObject
        $object = parent::hydrate($data, $object);

        // Gestion des relations
        $competences = $data['competences'] ?? null;
        $this->gererSousCompetencesRNCP($competences, $object);
        $this->gererSousCompetencesRNCP($data, $object);

        return $object;
    }

    private function gererSousCompetencesRNCP(array|null $idsSelectionnes, FormationExterne $formation): void
    private function gererSousCompetencesRNCP(array $data, FormationExterne $formation): void
    {
        $idsSelectionnes = array_map('intval', $idsSelectionnes ?? []);
        if ((!empty($data['competences']) && is_array($data['competences'])) || !isset($data['competences'])) {
            /** @var int[] $idsSelectionnes */
            $idsSelectionnes = array_map('intval', $data['competences'] ?? []);

            /** @var SousCompetence[] $actuelles */
            $actuelles = $this->getSousCompetenceService()
@@ -79,14 +80,14 @@ class FormationExterneHydrator extends DoctrineObject
            }

            //Ajout des nouvelles relations
            if ($formation->getId() !== null) {
                foreach ($idsSelectionnes as $id) {
            $sousCompetence = $this->getSousCompetenceService()
                ->getRepository()
                ->find($id);

                    $sousCompetence = $this->getSousCompetenceService()->getRepository()->find($id);
                    if ($sousCompetence instanceof SousCompetence) {
                        $formation->addSousCompetence($sousCompetence);
                    }
                }
            }
        }
    }
}
 No newline at end of file
Loading