From cd7ad4f5b4445db872d37a29e2554239dd1e9748 Mon Sep 17 00:00:00 2001 From: Jean-Philippe Metivier <jean-philippe.metivier@unicaen.fr> Date: Thu, 30 Sep 2021 15:07:36 +0200 Subject: [PATCH] EtatFieldset + usage dans les PPP --- .../Controller/AgentController.php | 32 +++++++++++++ .../Controller/AgentControllerFactory.php | 13 +++++ .../AgentAccompagnementForm.php | 11 ++++- .../AgentAccompagnementHydrator.php | 6 ++- .../Form/AgentPPP/AgentPPPForm.php | 11 ++++- .../Form/AgentPPP/AgentPPPHydrator.php | 6 ++- .../AgentStageObservationForm.php | 11 ++++- .../AgentStageObservationHydrator.php | 6 ++- .../Form/AgentTutorat/AgentTutoratForm.php | 11 ++++- .../AgentTutorat/AgentTutoratHydrator.php | 6 ++- .../UnicaenEtat/config/merged/etat.config.php | 3 ++ .../Form/EtatFieldset/EtatFieldset.php | 47 +++++++++++++++++++ .../Form/EtatFieldset/EtatFieldsetFactory.php | 21 +++++++++ 13 files changed, 168 insertions(+), 16 deletions(-) create mode 100644 module/UnicaenEtat/src/UnicaenEtat/Form/EtatFieldset/EtatFieldset.php create mode 100644 module/UnicaenEtat/src/UnicaenEtat/Form/EtatFieldset/EtatFieldsetFactory.php diff --git a/module/Application/src/Application/Controller/AgentController.php b/module/Application/src/Application/Controller/AgentController.php index cba0795c5..840997bf8 100644 --- a/module/Application/src/Application/Controller/AgentController.php +++ b/module/Application/src/Application/Controller/AgentController.php @@ -42,6 +42,8 @@ use Formation\Service\Formation\FormationServiceAwareTrait; use Formation\Service\FormationElement\FormationElementServiceAwareTrait; use Formation\Service\HasFormationCollection\HasFormationCollectionServiceAwareTrait; use UnicaenApp\Exception\RuntimeException; +use UnicaenEtat\Service\Etat\EtatServiceAwareTrait; +use UnicaenEtat\Service\EtatType\EtatTypeServiceAwareTrait; use UnicaenUtilisateur\Service\User\UserServiceAwareTrait; use UnicaenValidation\Entity\Db\ValidationInstance; use UnicaenValidation\Service\ValidationInstance\ValidationInstanceServiceAwareTrait; @@ -91,6 +93,9 @@ class AgentController extends AbstractActionController use AgentAccompagnementServiceAwareTrait; use AgentAccompagnementFormAwareTrait; + use EtatTypeServiceAwareTrait; + use EtatServiceAwareTrait; + public function indexAction() { $fromQueries = $this->params()->fromQuery(); @@ -393,6 +398,9 @@ class AgentController extends AbstractActionController $form->setAttribute('action', $this->url()->fromRoute('agent/ppp/ajouter', ['agent' => $agent->getId()], [], true)); $form->bind($ppp); + $type = $this->getEtatTypeService()->getEtatTypeByCode('PPP'); + $form->get('etat')->resetEtats($this->getEtatService()->getEtatsByType($type)); + $request = $this->getRequest(); if ($request->isPost()) { $data = $request->getPost(); @@ -419,6 +427,9 @@ class AgentController extends AbstractActionController $form->setAttribute('action', $this->url()->fromRoute('agent/ppp/modifier', ['ppp' => $ppp->getId()], [], true)); $form->bind($ppp); + $type = $this->getEtatTypeService()->getEtatTypeByCode('PPP'); + $form->get('etat')->resetEtats($this->getEtatService()->getEtatsByType($type)); + $request = $this->getRequest(); if ($request->isPost()) { $data = $request->getPost(); @@ -496,6 +507,10 @@ class AgentController extends AbstractActionController $form->setAttribute('action', $this->url()->fromRoute('agent/stageobs/ajouter', ['agent' => $agent->getId()], [], true)); $form->bind($stageObservation); + $type = $this->getEtatTypeService()->getEtatTypeByCode('STAGE_OBSERVATION'); + $form->get('etat')->resetEtats($this->getEtatService()->getEtatsByType($type)); + + $request = $this->getRequest(); if ($request->isPost()) { $data = $request->getPost(); @@ -522,6 +537,9 @@ class AgentController extends AbstractActionController $form->setAttribute('action', $this->url()->fromRoute('agent/stageobs/modifier', ['stageobs' => $stageObservation->getId()], [], true)); $form->bind($stageObservation); + $type = $this->getEtatTypeService()->getEtatTypeByCode('STAGE_OBSERVATION'); + $form->get('etat')->resetEtats($this->getEtatService()->getEtatsByType($type)); + $request = $this->getRequest(); if ($request->isPost()) { $data = $request->getPost(); @@ -599,6 +617,10 @@ class AgentController extends AbstractActionController $form->setAttribute('action', $this->url()->fromRoute('agent/tutorat/ajouter', ['agent' => $agent->getId()], [], true)); $form->bind($tutorat); + $type = $this->getEtatTypeService()->getEtatTypeByCode('TUTORAT'); + $form->get('etat')->resetEtats($this->getEtatService()->getEtatsByType($type)); + + $request = $this->getRequest(); if ($request->isPost()) { $data = $request->getPost(); @@ -625,6 +647,9 @@ class AgentController extends AbstractActionController $form->setAttribute('action', $this->url()->fromRoute('agent/tutorat/modifier', ['tutorat' => $tutorat->getId()], [], true)); $form->bind($tutorat); + $type = $this->getEtatTypeService()->getEtatTypeByCode('TUTORAT'); + $form->get('etat')->resetEtats($this->getEtatService()->getEtatsByType($type)); + $request = $this->getRequest(); if ($request->isPost()) { $data = $request->getPost(); @@ -702,6 +727,9 @@ class AgentController extends AbstractActionController $form->setAttribute('action', $this->url()->fromRoute('agent/accompagnement/ajouter', ['agent' => $agent->getId()], [], true)); $form->bind($accompagnement); + $type = $this->getEtatTypeService()->getEtatTypeByCode('ACCOMPAGNEMENT'); + $form->get('etat')->resetEtats($this->getEtatService()->getEtatsByType($type)); + $request = $this->getRequest(); if ($request->isPost()) { $data = $request->getPost(); @@ -728,6 +756,10 @@ class AgentController extends AbstractActionController $form->setAttribute('action', $this->url()->fromRoute('agent/accompagnement/modifier', ['accompagnement' => $accompagnement->getId()], [], true)); $form->bind($accompagnement); + $type = $this->getEtatTypeService()->getEtatTypeByCode('ACCOMPAGNEMENT'); + $form->get('etat')->resetEtats($this->getEtatService()->getEtatsByType($type)); + + $request = $this->getRequest(); if ($request->isPost()) { $data = $request->getPost(); diff --git a/module/Application/src/Application/Controller/AgentControllerFactory.php b/module/Application/src/Application/Controller/AgentControllerFactory.php index dd445099c..d149d5ea6 100644 --- a/module/Application/src/Application/Controller/AgentControllerFactory.php +++ b/module/Application/src/Application/Controller/AgentControllerFactory.php @@ -31,6 +31,8 @@ use Formation\Service\Formation\FormationService; use Formation\Service\FormationElement\FormationElementService; use Formation\Service\HasFormationCollection\HasFormationCollectionService; use Interop\Container\ContainerInterface; +use UnicaenEtat\Service\Etat\EtatService; +use UnicaenEtat\Service\EtatType\EtatTypeService; use UnicaenUtilisateur\Service\User\UserService; use UnicaenValidation\Service\ValidationInstance\ValidationInstanceService; use UnicaenValidation\Service\ValidationType\ValidationTypeService; @@ -151,6 +153,17 @@ class AgentControllerFactory { $controller->setAgentTutoratForm($agentTutoratForm); $controller->setAgentAccompagnementService($agentAccompagnementService); $controller->setAgentAccompagnementForm($agentAccompagnementForm); + + /** + * @var EtatService $etatService + * @var EtatTypeService $etatTypeService + */ + $etatService = $container->get(EtatService::class); + $etatTypeService = $container->get(EtatTypeService::class); + + $controller->setEtatService($etatService); + $controller->setEtatTypeService($etatTypeService); + return $controller; } } \ No newline at end of file diff --git a/module/Application/src/Application/Form/AgentAccompagnement/AgentAccompagnementForm.php b/module/Application/src/Application/Form/AgentAccompagnement/AgentAccompagnementForm.php index 025ee8c86..246537e51 100644 --- a/module/Application/src/Application/Form/AgentAccompagnement/AgentAccompagnementForm.php +++ b/module/Application/src/Application/Form/AgentAccompagnement/AgentAccompagnementForm.php @@ -7,6 +7,7 @@ use Application\Service\Agent\AgentServiceAwareTrait; use Application\Service\Corps\CorpsServiceAwareTrait; use Application\Service\Correspondance\CorrespondanceServiceAwareTrait; use UnicaenApp\Form\Element\SearchAndSelect; +use UnicaenEtat\Form\EtatFieldset\EtatFieldset; use UnicaenEtat\Service\Etat\EtatServiceAwareTrait; use Zend\Form\Element\Button; use Zend\Form\Element\Select; @@ -71,8 +72,14 @@ class AgentAccompagnementForm extends Form 'id' => 'periode', ] ]); - // etat TODO - //$this->get('etat')->setValueOptions($this->getEtatService()->getEtatsAsOption($type)); + // etat + $this->add([ + 'name' => 'etat', + 'type' => EtatFieldset::class, + 'attributes' => [ + 'id' => 'etat', + ] + ]); // complement $this->add([ diff --git a/module/Application/src/Application/Form/AgentAccompagnement/AgentAccompagnementHydrator.php b/module/Application/src/Application/Form/AgentAccompagnement/AgentAccompagnementHydrator.php index 921b486c4..1d3970eac 100644 --- a/module/Application/src/Application/Form/AgentAccompagnement/AgentAccompagnementHydrator.php +++ b/module/Application/src/Application/Form/AgentAccompagnement/AgentAccompagnementHydrator.php @@ -31,7 +31,9 @@ class AgentAccompagnementHydrator implements HydratorInterface { 'date_debut' => ($object->getDateDebut())?$object->getDateDebut()->format('d/m/Y'):null, 'date_fin' => ($object->getDateFin())?$object->getDateFin()->format('d/m/Y'):null, ], - 'etat' => ($object->getEtat())?$object->getEtat()->getId():null, + 'etat' => [ + 'etat' => ($object->getEtat())?$object->getEtat()->getId():null, + ], 'complement' => $object->getComplement(), 'resutlat' => $object->getResultat(), ]; @@ -50,7 +52,7 @@ class AgentAccompagnementHydrator implements HydratorInterface { $corps = (isset($data['corps']) AND trim($data['corps']) !== '')?$this->getCorpsService()->getCorp($data['corps']):null; $dataDebut = (isset($data['HasPeriode']) AND isset($data['HasPeriode']['date_debut']) AND trim($data['HasPeriode']['date_debut']) !== '')?DateTime::createFromFormat(HasPeriodeFieldset::format, $data['HasPeriode']['date_debut']):null; $dateFin = (isset($data['HasPeriode']) AND isset($data['HasPeriode']['date_fin']) AND trim($data['HasPeriode']['date_fin']) !== '')?DateTime::createFromFormat(HasPeriodeFieldset::format, $data['HasPeriode']['date_fin']):null; - $etat = (isset($data['etat']))?$this->getEtatService()->getEtat($data['etat']):null; + $etat = (isset($data['etat']) AND isset($data['etat']['etat']))?$this->getEtatService()->getEtat($data['etat']['etat']):null; $complement = (isset($data['complement']) AND trim($data['complement']) !== '')?trim($data['complement']):null; $resultat = (isset($data['resultat']) AND trim($data['resultat']) !== '')?($data['resultat']):null; diff --git a/module/Application/src/Application/Form/AgentPPP/AgentPPPForm.php b/module/Application/src/Application/Form/AgentPPP/AgentPPPForm.php index cdd85233b..972dc5cc8 100644 --- a/module/Application/src/Application/Form/AgentPPP/AgentPPPForm.php +++ b/module/Application/src/Application/Form/AgentPPP/AgentPPPForm.php @@ -3,6 +3,7 @@ namespace Application\Form\AgentPPP; use Application\Form\HasPeriode\HasPeriodeFieldset; +use UnicaenEtat\Form\EtatFieldset\EtatFieldset; use UnicaenEtat\Service\Etat\EtatServiceAwareTrait; use Zend\Form\Element\Button; use Zend\Form\Element\Number; @@ -60,8 +61,14 @@ class AgentPPPForm extends Form { 'id' => 'periode', ] ]); - // etat TODO - //$this->get('etat')->setValueOptions($this->getEtatService()->getEtatsAsOption($type)); + /// etat + $this->add([ + 'name' => 'etat', + 'type' => EtatFieldset::class, + 'attributes' => [ + 'id' => 'etat', + ] + ]); // Utilisation du cpf $this->add([ diff --git a/module/Application/src/Application/Form/AgentPPP/AgentPPPHydrator.php b/module/Application/src/Application/Form/AgentPPP/AgentPPPHydrator.php index a481142b1..875331ba8 100644 --- a/module/Application/src/Application/Form/AgentPPP/AgentPPPHydrator.php +++ b/module/Application/src/Application/Form/AgentPPP/AgentPPPHydrator.php @@ -24,7 +24,9 @@ class AgentPPPHydrator implements HydratorInterface { 'date_debut' => ($object->getDateDebut())?$object->getDateDebut()->format('d/m/Y'):null, 'date_fin' => ($object->getDateFin())?$object->getDateFin()->format('d/m/Y'):null, ], - 'etat' => ($object->getEtat())?$object->getEtat()->getId():null, + 'etat' => [ + 'etat' => ($object->getEtat())?$object->getEtat()->getId():null, + ], 'cpf' => $object->getFormationCPF(), 'cout' => $object->getFormationCout(), 'priseencharge' => $object->getFormationPriseEnCharge(), @@ -45,7 +47,7 @@ class AgentPPPHydrator implements HydratorInterface { $libelle = (isset($data['libelle']) AND trim($data['libelle']) !== '')?trim($data['libelle']):null; $dataDebut = (isset($data['HasPeriode']) AND isset($data['HasPeriode']['date_debut']) AND trim($data['HasPeriode']['date_debut']) !== '')?DateTime::createFromFormat(HasPeriodeFieldset::format, $data['HasPeriode']['date_debut']):null; $dateFin = (isset($data['HasPeriode']) AND isset($data['HasPeriode']['date_fin']) AND trim($data['HasPeriode']['date_fin']) !== '')?DateTime::createFromFormat(HasPeriodeFieldset::format, $data['HasPeriode']['date_fin']):null; - $etat = (isset($data['etat']))?$this->getEtatService()->getEtat($data['etat']):null; + $etat = (isset($data['etat']) AND isset($data['etat']['etat']))?$this->getEtatService()->getEtat($data['etat']['etat']):null; $cpf = (isset($data['cpf']) AND trim($data['cpf']) !== '')?$data['cpf']:null; $cout = (isset($data['cout']) AND trim($data['cout']) !== '')?$data['cout']:null; $priseencharge = (isset($data['priseencharge']) AND trim($data['priseencharge']) !== '')?$data['priseencharge']:null; diff --git a/module/Application/src/Application/Form/AgentStageObservation/AgentStageObservationForm.php b/module/Application/src/Application/Form/AgentStageObservation/AgentStageObservationForm.php index 5b5472130..23fb18462 100644 --- a/module/Application/src/Application/Form/AgentStageObservation/AgentStageObservationForm.php +++ b/module/Application/src/Application/Form/AgentStageObservation/AgentStageObservationForm.php @@ -5,6 +5,7 @@ namespace Application\Form\AgentStageObservation; use Application\Form\HasPeriode\HasPeriodeFieldset; use Application\Service\Structure\StructureServiceAwareTrait; use Metier\Service\Metier\MetierServiceAwareTrait; +use UnicaenEtat\Form\EtatFieldset\EtatFieldset; use UnicaenEtat\Service\Etat\EtatServiceAwareTrait; use Zend\Form\Element\Button; use Zend\Form\Element\Select; @@ -55,8 +56,14 @@ class AgentStageObservationForm extends Form { 'id' => 'periode', ] ]); - // etat TODO - //$this->get('etat')->setValueOptions($this->getEtatService()->getEtatsAsOption($type)); + // etat + $this->add([ + 'name' => 'etat', + 'type' => EtatFieldset::class, + 'attributes' => [ + 'id' => 'etat', + ] + ]); // complement $this->add([ diff --git a/module/Application/src/Application/Form/AgentStageObservation/AgentStageObservationHydrator.php b/module/Application/src/Application/Form/AgentStageObservation/AgentStageObservationHydrator.php index ad48e32b6..5f4120793 100644 --- a/module/Application/src/Application/Form/AgentStageObservation/AgentStageObservationHydrator.php +++ b/module/Application/src/Application/Form/AgentStageObservation/AgentStageObservationHydrator.php @@ -28,7 +28,9 @@ class AgentStageObservationHydrator implements HydratorInterface { 'date_debut' => ($object->getDateDebut())?$object->getDateDebut()->format('d/m/Y'):null, 'date_fin' => ($object->getDateFin())?$object->getDateFin()->format('d/m/Y'):null, ], - 'etat' => ($object->getEtat())?$object->getEtat()->getId():null, + 'etat' => [ + 'etat' => ($object->getEtat())?$object->getEtat()->getId():null, + ], 'complement' => $object->getComplement(), ]; return $data; @@ -45,7 +47,7 @@ class AgentStageObservationHydrator implements HydratorInterface { $metier = (isset($data['metier']) AND trim($data['metier']) !== '')?$this->getMetierService()->getMetier($data['metier']):null; $dataDebut = (isset($data['HasPeriode']) AND isset($data['HasPeriode']['date_debut']) AND trim($data['HasPeriode']['date_debut']) !== '')?DateTime::createFromFormat(HasPeriodeFieldset::format, $data['HasPeriode']['date_debut']):null; $dateFin = (isset($data['HasPeriode']) AND isset($data['HasPeriode']['date_fin']) AND trim($data['HasPeriode']['date_fin']) !== '')?DateTime::createFromFormat(HasPeriodeFieldset::format, $data['HasPeriode']['date_fin']):null; - $etat = (isset($data['etat']))?$this->getEtatService()->getEtat($data['etat']):null; + $etat = (isset($data['etat']) AND isset($data['etat']['etat']))?$this->getEtatService()->getEtat($data['etat']['etat']):null; $complement = (isset($data['complement']) AND trim($data['complement']) !== '')?trim($data['complement']):null; $object->setStructure($structure); diff --git a/module/Application/src/Application/Form/AgentTutorat/AgentTutoratForm.php b/module/Application/src/Application/Form/AgentTutorat/AgentTutoratForm.php index 2d9171f77..ef687da50 100644 --- a/module/Application/src/Application/Form/AgentTutorat/AgentTutoratForm.php +++ b/module/Application/src/Application/Form/AgentTutorat/AgentTutoratForm.php @@ -6,6 +6,7 @@ use Application\Form\HasPeriode\HasPeriodeFieldset; use Application\Service\Agent\AgentServiceAwareTrait; use Metier\Service\Metier\MetierServiceAwareTrait; use UnicaenApp\Form\Element\SearchAndSelect; +use UnicaenEtat\Form\EtatFieldset\EtatFieldset; use UnicaenEtat\Service\Etat\EtatServiceAwareTrait; use Zend\Form\Element\Button; use Zend\Form\Element\Select; @@ -55,8 +56,14 @@ class AgentTutoratForm extends Form 'id' => 'periode', ] ]); - // etat TODO - //$this->get('etat')->setValueOptions($this->getEtatService()->getEtatsAsOption($type)); + // etat + $this->add([ + 'name' => 'etat', + 'type' => EtatFieldset::class, + 'attributes' => [ + 'id' => 'etat', + ] + ]); // complement $this->add([ diff --git a/module/Application/src/Application/Form/AgentTutorat/AgentTutoratHydrator.php b/module/Application/src/Application/Form/AgentTutorat/AgentTutoratHydrator.php index ef2410e00..36daa5c28 100644 --- a/module/Application/src/Application/Form/AgentTutorat/AgentTutoratHydrator.php +++ b/module/Application/src/Application/Form/AgentTutorat/AgentTutoratHydrator.php @@ -28,7 +28,9 @@ class AgentTutoratHydrator implements HydratorInterface { 'date_debut' => ($object->getDateDebut())?$object->getDateDebut()->format('d/m/Y'):null, 'date_fin' => ($object->getDateFin())?$object->getDateFin()->format('d/m/Y'):null, ], - 'etat' => ($object->getEtat())?$object->getEtat()->getId():null, + 'etat' => [ + 'etat' => ($object->getEtat())?$object->getEtat()->getId():null, + ], 'complement' => $object->getComplement(), 'formation' => $object->getFormation(), ]; @@ -46,7 +48,7 @@ class AgentTutoratHydrator implements HydratorInterface { $metier = (isset($data['metier']) AND trim($data['metier']) !== '')?$this->getMetierService()->getMetier($data['metier']):null; $dataDebut = (isset($data['HasPeriode']) AND isset($data['HasPeriode']['date_debut']) AND trim($data['HasPeriode']['date_debut']) !== '')?DateTime::createFromFormat(HasPeriodeFieldset::format, $data['HasPeriode']['date_debut']):null; $dateFin = (isset($data['HasPeriode']) AND isset($data['HasPeriode']['date_fin']) AND trim($data['HasPeriode']['date_fin']) !== '')?DateTime::createFromFormat(HasPeriodeFieldset::format, $data['HasPeriode']['date_fin']):null; - $etat = (isset($data['etat']))?$this->getEtatService()->getEtat($data['etat']):null; + $etat = (isset($data['etat']) AND isset($data['etat']['etat']))?$this->getEtatService()->getEtat($data['etat']['etat']):null; $complement = (isset($data['complement']) AND trim($data['complement']) !== '')?trim($data['complement']):null; $formation = (isset($data['formation']) AND trim($data['formation']) !== '')?($data['formation']):null; diff --git a/module/UnicaenEtat/config/merged/etat.config.php b/module/UnicaenEtat/config/merged/etat.config.php index e25f73de7..65f445e83 100644 --- a/module/UnicaenEtat/config/merged/etat.config.php +++ b/module/UnicaenEtat/config/merged/etat.config.php @@ -8,6 +8,8 @@ use UnicaenEtat\Form\Etat\EtatForm; use UnicaenEtat\Form\Etat\EtatFormFactory; use UnicaenEtat\Form\Etat\EtatHydrator; use UnicaenEtat\Form\Etat\EtatHydratorFactory; +use UnicaenEtat\Form\EtatFieldset\EtatFieldset; +use UnicaenEtat\Form\EtatFieldset\EtatFieldsetFactory; use UnicaenEtat\Form\SelectionEtat\SelectionEtatForm; use UnicaenEtat\Form\SelectionEtat\SelectionEtatFormFactory; use UnicaenEtat\Form\SelectionEtat\SelectionEtatHydrator; @@ -187,6 +189,7 @@ return [ ], 'form_elements' => [ 'factories' => [ + EtatFieldset::class => EtatFieldsetFactory::class, EtatForm::class => EtatFormFactory::class, SelectionEtatForm::class => SelectionEtatFormFactory::class, ], diff --git a/module/UnicaenEtat/src/UnicaenEtat/Form/EtatFieldset/EtatFieldset.php b/module/UnicaenEtat/src/UnicaenEtat/Form/EtatFieldset/EtatFieldset.php new file mode 100644 index 000000000..67030a818 --- /dev/null +++ b/module/UnicaenEtat/src/UnicaenEtat/Form/EtatFieldset/EtatFieldset.php @@ -0,0 +1,47 @@ +<?php + +namespace UnicaenEtat\Form\EtatFieldset; + +use UnicaenEtat\Entity\Db\Etat; +use UnicaenEtat\Service\Etat\EtatServiceAwareTrait; +use Zend\Form\Element\Select; +use Zend\Form\Fieldset; + +class EtatFieldset extends Fieldset +{ + use EtatServiceAwareTrait; + + public function init() + { + $this->add([ + 'type' => Select::class, + 'name' => 'etat', + 'options' => [ + 'label' => "État * :", + 'empty_option' => "Sélectionner un état ...", + 'value_options' => $this->getEtatService()->getEtatsAsOption(), + ], + 'attributes' => [ + 'id' => 'etat', + 'class' => 'bootstrap-selectpicker show-tick', + 'data-live-search' => 'true', + ], + ]); + } + + /** + * @param Etat[] $etats + */ + public function resetEtats(array $etats) + { + $options = []; + /** @var Etat $etat */ + foreach ($etats as $etat) { + $options[$etat->getId()] = $this->getEtatService()->optionify($etat); + } + + /** @var Select $select */ + $select = $this->get('etat'); + $select->setValueOptions($options); + } +} \ No newline at end of file diff --git a/module/UnicaenEtat/src/UnicaenEtat/Form/EtatFieldset/EtatFieldsetFactory.php b/module/UnicaenEtat/src/UnicaenEtat/Form/EtatFieldset/EtatFieldsetFactory.php new file mode 100644 index 000000000..d5ee43652 --- /dev/null +++ b/module/UnicaenEtat/src/UnicaenEtat/Form/EtatFieldset/EtatFieldsetFactory.php @@ -0,0 +1,21 @@ +<?php + +namespace UnicaenEtat\Form\EtatFieldset; + +use Interop\Container\ContainerInterface; +use UnicaenEtat\Service\Etat\EtatService; + +class EtatFieldsetFactory { + + public function __invoke(ContainerInterface $container) + { + /** + * @var EtatService $etatService + */ + $etatService = $container->get(EtatService::class); + + $fieldset = new EtatFieldset(); + $fieldset->setEtatService($etatService); + return $fieldset; + } +} \ No newline at end of file -- GitLab