Commit f61edf26 authored by Laurent Lecluse's avatar Laurent Lecluse
Browse files

Correction de bugs suite refactoring

parent 9244f6ae
Loading
Loading
Loading
Loading
+2 −1
Changes for module/Application/config/offre-formation.config.php: 2 added lines, 1 removed line.
Original line number Diff line number Diff line
@@ -213,7 +213,8 @@ return [
                            'ajouter'       => [
                                'type'    => 'Segment',
                                'options' => [
                                    'route'    => '/ajouter',
                                    'route'       => '/ajouter/:structure',
                                    'constraints' => ['structure' => '[0-9]*'],
                                    'defaults'    => ['action' => 'saisir'],
                                ],
                            ],
+8 −17
Changes for module/Application/src/Controller/OffreFormation/EtapeController.php: 8 added lines, 17 removed lines.
Original line number Diff line number Diff line
@@ -5,6 +5,7 @@ namespace Application\Controller\OffreFormation;
use Application\Controller\AbstractController;
use Application\Entity\Db\DomaineFonctionnel;
use Application\Entity\Db\ElementPedagogique;
use Application\Entity\Db\Etape;
use Application\Entity\Db\Structure;
use Application\Entity\Db\TypeFormation;
use Application\Form\OffreFormation\TauxMixite\Traits\TauxMixiteFormAwareTrait;
@@ -36,34 +37,24 @@ class EtapeController extends AbstractController
            Structure::class,
        ]);

        $structure = $this->em()->find(Structure::class, $this->params()->fromRoute('structure'));
        $etape     = $this->getEvent()->getParam('etape');

        $title  = $etape ? "Modification d'une formation" : "Création d'une nouvelle formation";
        $form   = $this->getFormOffreFormationEtapeSaisie();
        $errors = [];

        if ($etape) {
            $form->bind($etape);
        } else {
        if (!$etape) {
            $etape = $this->getServiceEtape()->newEntity();
            $form->setObject($etape);
            $etape->setStructure($structure);
        }

        $form->setAttribute('action', $this->url()->fromRoute(null, [], [], true));

        $request = $this->getRequest();
        if ($request->isPost()) {
            $form->setData($request->getPost());
            if ($form->isValid()) {
                try {
        $form->bindRequestSave($etape, $this->getRequest(), function (Etape $etape) use ($form) {
            $this->getServiceEtape()->save($etape);
            $form->get('id')->setValue($etape->getId()); // transmet le nouvel ID
                } catch (\Exception $e) {
                    $errors[] = $this->translate($e);
                }
            }
        }
        });

        return compact('form', 'title', 'errors');
        return compact('form', 'title');
    }


+1 −1
Changes for module/Application/src/Entity/Db/GroupeTypeFormation.php: 1 added line, 1 removed line.
Original line number Diff line number Diff line
@@ -128,7 +128,7 @@ class GroupeTypeFormation implements HistoriqueAwareInterface, ImportAwareInterf
    /**
     * @return bool
     */
    public function isPertinenceNiveau(): bool
    public function getPertinenceNiveau(): bool
    {
        return $this->pertinenceNiveau;
    }
+1
Changes for module/Application/src/Form/OffreFormation/EtapeSaisie.php: 1 added line, 0 removed lines.
Original line number Diff line number Diff line
@@ -40,6 +40,7 @@ class EtapeSaisie extends AbstractForm
        $hydrator->setServiceTypeFormation($this->getServiceTypeFormation());
        $this->setHydrator($hydrator);
        $this->setAttribute('class', 'etape-saisie');
        $this->setAttribute('action', $this->getCurrentUrl());

        /* construction du formulaire */
        $this->add([
+3 −2
Changes for module/Application/src/View/Helper/OffreFormation/EtapeViewHelper.php: 3 added lines, 2 removed lines.
Original line number Diff line number Diff line
@@ -3,6 +3,7 @@
namespace Application\View\Helper\OffreFormation;

use Application\Entity\Db\Etape as Entity;
use Application\Entity\Db\Structure;
use Application\Entity\Db\Traits\EtapeAwareTrait;
use Application\Provider\Privilege\Privileges;
use Application\Service\Traits\EtapeServiceAwareTrait as ServiceEtapeAwareTrait;
@@ -140,12 +141,12 @@ class EtapeViewHelper extends AbstractViewHelper



    public function renderAjouterLink($content = '', $attributes = [])
    public function renderAjouterLink(string $content, array $attributes, Structure $structure)
    {
        if (!$content) $content = '<i class="fas fa-plus"></i> Ajouter une formation';

        $default = [
            'href'       => $this->getView()->url('of/etape/ajouter'),
            'href'       => $this->getView()->url('of/etape/ajouter', ['structure' => $structure->getId()]),
            'class'      => ['etape-ajouter-link', 'ajax-modal', 'iconify', 'btn', 'btn-default'],
            'data-event' => 'etape-ajouter',
            'title'      => 'Ajouter une formation',
Loading