Commit 645bbd38 authored by Jean-Philippe Metivier's avatar Jean-Philippe Metivier
Browse files

Ajout de des axes de formations

parent f0aced74
Loading
Loading
Loading
Loading
+88 −0
Changes for config/autoload/database.local.php.dist: 88 added lines, 0 removed lines.
Original line number Diff line number Diff line
<?php

use Doctrine\DBAL\Driver\PgSQL\Driver;
use Doctrine\ORM\Mapping\Driver\XmlDriver;
use Doctrine\Persistence\Mapping\Driver\MappingDriverChain;

$env = getenv('APPLICATION_ENV') ?: 'production';

return [

    'doctrine' => [
        'driver' => [
            'orm_octopus' => [
                'class' => MappingDriverChain::class,
                'drivers' => [
                    'Application\Entity\Db' => 'orm_octopus_xml_driver',
                ],
            ],
            'orm_octopus_xml_driver' => [
                'class' => XmlDriver::class,
                'cache' => 'apc',
                'paths' => [
                    __DIR__ . '/../src/Application/Entity/Db/Mapping',
                ],
            ],
        ],
        'cache' => [
            'apc' => [
                'namespace' => 'PREECOG__' . __NAMESPACE__,
            ],
        ],
        'connection' => [
            // base de l'application
            'orm_default' => [
                'driverClass' => Driver::class,
                'params' => [
                    'host' => 'pgsql.mon-etablissement.fr',
                    'port' => '5432',
                    'charset' => 'utf8',
                    'driverOptions' => [1002 => 'SET NAMES utf8'],
                    'user' => 'USERNAME',
                    'password' => 'PASSWORD',
                    'dbname' => 'DB_NAME',
                ],
            ],
            'orm_octopus' => [
                'driverClass' => Driver::class, // Si PgSQL
                // 'driverClass' => Doctrine\DBAL\Driver\OCI8\Driver::class, // Si oracle
                'params' => [
                    'host' => 'sirh.mon-etablissement.fr',
                    'port' => '1234',
                    'user' => 'USERNAME',
                    'password' => 'PASSWORD',
                    'service' => 'DB_NAME',
                    'servicename' => 'DB_NAME',
                    'charset' => 'AL32UTF8',
                ],
            ],
        ],
        'entitymanager' => [
            'orm_default' => [
                'connection' => 'orm_default',
                'configuration' => 'orm_default',
            ],
            'orm_octopus' => [
                'connection' => 'orm_octopus',
                'configuration' => 'orm_octopus',
            ],
        ],
        'configuration' => [
            'orm_default' => [
                'metadata_cache' => 'array',
                'query_cache' => 'array',
                'result_cache' => 'array',
                'hydration_cache' => 'array',
                'generate_proxies' => true,
            ],
            'orm_octopus' => [
                'metadata_cache' => 'array',
                'query_cache' => 'array',
                'result_cache' => 'array',
                'hydration_cache' => 'array',
                'generate_proxies' => true,
                'driver' => 'orm_octopus',
            ],
        ],
    ],
];
 No newline at end of file
+67 −0
Changes for documentation/release/4.1.2.md: 67 added lines, 0 removed lines.
Original line number Diff line number Diff line
Version 4.X.X (XX/11/2023)
====

Évolution
---
- Mes Formations : Axe comme élément de chapeau des groupes

Modification en BD
---

```postgresql
-- Nouvelle table pour les axes
create table formation_axe
(
    id                    serial                  not null
        constraint formation_axe_pk
            primary key,
    libelle               varchar(1024)           not null,
    description           text,
    ordre                 integer   default 9999  not null,
    histo_creation        timestamp default now() not null,
    histo_createur_id     integer   default 0     not null
        constraint formation_axe_unicaen_utilisateur_user_id_fk
            references unicaen_utilisateur_user,
    histo_modification    timestamp,
    histo_modificateur_id integer
        constraint formation_axe_unicaen_utilisateur_user_id_fk2
            references unicaen_utilisateur_user,
    hsto_destruction      timestamp,
    histo_destructeur_id  integer
        constraint formation_axe_unicaen_utilisateur_user_id_fk3
            references unicaen_utilisateur_user
);

-- Colonne pour les axes dans les groupes
alter table formation_groupe add axe_id integer;
alter table formation_groupe
    add constraint formation_groupe_formation_axe_id_fk
        foreign key (axe_id) references formation_axe on delete set null;


```

Evolution des librairies
---



```bash
```

Mise à jour des bibliothèque pour PHP8.2
```bash
## Faire la montée en version de votre php, et de vos drivers
composer update
```

ou

```bash
rm -fr vendor
rm -fr composer.lock
composer install
```

Evolution des macros et templates
---
+201 −0
Changes for module/Formation/config/merged/axe.config.php: 201 added lines, 0 removed lines.
Original line number Diff line number Diff line
<?php

namespace Formation;

use Formation\Controller\AxeController;
use Formation\Controller\AxeControllerFactory;
use Formation\Form\Axe\AxeForm;
use Formation\Form\Axe\AxeFormFactory;
use Formation\Form\Axe\AxeHydrator;
use Formation\Form\Axe\AxeHydratorFactory;
use Formation\Provider\Privilege\AxePrivileges;
use Formation\Service\Axe\AxeService;
use Formation\Service\Axe\AxeServiceFactory;
use UnicaenPrivilege\Guard\PrivilegeController;
use Laminas\Router\Http\Literal;
use Laminas\Router\Http\Segment;

return [
    'bjyauthorize' => [
        'guards' => [
            PrivilegeController::class => [
                [
                    'controller' => AxeController::class,
                    'action' => [
                        'index',
                    ],
                    'privileges' => [
                        AxePrivileges::AXE_INDEX,
                    ],
                ],
                [
                    'controller' => AxeController::class,
                    'action' => [
                        'afficher',
                    ],
                    'privileges' => [
                        AxePrivileges::AXE_AFFICHER,
                    ],
                ],
                [
                    'controller' => AxeController::class,
                    'action' => [
                        'ajouter',
                    ],
                    'privileges' => [
                        AxePrivileges::AXE_AJOUTER,
                    ],
                ],
                [
                    'controller' => AxeController::class,
                    'action' => [
                        'modifier',
                    ],
                    'privileges' => [
                        AxePrivileges::AXE_MODIFIER,
                    ],
                ],
                [
                    'controller' => AxeController::class,
                    'action' => [
                        'historiser',
                        'restaurer',
                    ],
                    'privileges' => [
                        AxePrivileges::AXE_HISTORISER,
                    ],
                ],
                [
                    'controller' => AxeController::class,
                    'action' => [
                        'supprimer',
                    ],
                    'privileges' => [
                        AxePrivileges::AXE_SUPPRIMER,
                    ],
                ],
            ],
        ],
    ],

    'navigation'      => [
        'formation' => [
            'home' => [
                'pages' => [
                    'gestion-formation' => [
                        'pages' => [
                            'axe' => [
                                'label'    => 'Axe de formation',
                                'route'    => 'axe',
                                'resource' => PrivilegeController::getResourceId(AxeController::class, 'index') ,
                                'order'    => 205,
                                'icon' => 'fas fa-angle-right',
                            ],
                        ],
                    ],
                ],
            ],
        ],
    ],

    'router' => [
        'routes' => [
            'axe' => [
                'type'  => Literal::class,
                'options' => [
                    'route'    => '/axe',
                    'defaults' => [
                        /** @see AxeController::indexAction() */
                        'controller' => AxeController::class,
                        'action' => 'index',
                    ],
                ],
                'may_terminate' => true,
                'child_routes' => [
                    'afficher' => [
                        'type'  => Segment::class,
                        'options' => [
                            'route'    => '/afficher/:axe',
                            'defaults' => [
                                /** @see AxeController::afficherAction() */
                                'action'     => 'afficher',
                            ],
                        ],
                    ],
                    'ajouter' => [
                        'type'  => Literal::class,
                        'options' => [
                            'route'    => '/ajouter',
                            'defaults' => [
                                /** @see AxeController::ajouterAction() */
                                'action'     => 'ajouter',
                            ],
                        ],
                    ],
                    'modifier' => [
                        'type'  => Segment::class,
                        'options' => [
                            'route'    => '/modifier/:axe',
                            'defaults' => [
                                /** @see AxeController::modifierAction() */
                                'action'     => 'modifier',
                            ],
                        ],
                    ],
                    'historiser' => [
                        'type'  => Segment::class,
                        'options' => [
                            'route'    => '/historiser/:axe',
                            'defaults' => [
                                /** @see AxeController::historiserAction() */
                                'action'     => 'historiser',
                            ],
                        ],
                    ],
                    'restaurer' => [
                        'type'  => Segment::class,
                        'options' => [
                            'route'    => '/restaurer/:axe',
                            'defaults' => [
                                /** @see AxeController::restaurerAction() */
                                'action'     => 'restaurer',
                            ],
                        ],
                    ],
                    'supprimer' => [
                        'type'  => Segment::class,
                        'options' => [
                            'route'    => '/supprimer/:axe',
                            'defaults' => [
                                /** @see AxeController::supprimerAction() */
                                'action'     => 'supprimer',
                            ],
                        ],
                    ],
                ],
            ],
        ],
    ],

    'service_manager' => [
        'factories' => [
            AxeService::class => AxeServiceFactory::class,
        ],
    ],
    'controllers'     => [
        'factories' => [
            AxeController::class => AxeControllerFactory::class,
        ],
    ],
    'form_elements' => [
        'factories' => [
            AxeForm::class => AxeFormFactory::class,
        ],
    ],
    'hydrators' => [
        'factories' => [
            AxeHydrator::class => AxeHydratorFactory::class,
        ],
    ]

];
 No newline at end of file
+129 −0
Changes for module/Formation/src/Formation/Controller/AxeController.php: 129 added lines, 0 removed lines.
Original line number Diff line number Diff line
<?php

namespace Formation\Controller;

use Formation\Entity\Db\Axe;
use Formation\Form\Axe\AxeFormAwareTrait;
use Formation\Service\Axe\AxeServiceAwareTrait;
use Laminas\Http\Response;
use Laminas\Mvc\Controller\AbstractActionController;
use Laminas\View\Model\ViewModel;

class AxeController extends AbstractActionController {
    use AxeServiceAwareTrait;
    use AxeFormAwareTrait;

    public function indexAction(): ViewModel
    {
        $axes = $this->getAxeService()->getAxes('ordre', 'ASC', true);

        return new ViewModel([
            'axes' => $axes,
        ]);
    }

    public function afficherAction(): ViewModel
    {
        $axe = $this->getAxeService()->getRequestedAxe($this);

        return new ViewModel([
            'title' => "Affichage de l'axe [".$axe->getLibelle()."]",
            'axe' => $axe,
        ]);
    }

    public function ajouterAction(): ViewModel
    {
        $axe = new Axe();

        $form = $this->getAxeForm();
        $form->setAttribute('action', $this->url()->fromRoute('axe/ajouter', [], [], true));
        $form->bind($axe);

        $request = $this->getRequest();
        if ($request->isPost()) {
            $data = $request->getPost();
            $form->setData($data);
            if ($form->isValid()) {
                $this->getAxeService()->create($axe);
                exit();
            }
        }

        $vm = new ViewModel([
            'title' => "Ajout d'un axe de formation",
            'form' => $form,
        ]);
        $vm->setTemplate('default/default-form');
        return $vm;
    }

    public function modifierAction(): ViewModel
    {
        $axe = $this->getAxeService()->getRequestedAxe($this);

        $form = $this->getAxeForm();
        $form->setAttribute('action', $this->url()->fromRoute('axe/modifier', ['axe' => $axe->getId()], [], true));
        $form->bind($axe);

        $request = $this->getRequest();
        if ($request->isPost()) {
            $data = $request->getPost();
            $form->setData($data);
            if ($form->isValid()) {
                $this->getAxeService()->update($axe);
                exit();
            }
        }

        $vm = new ViewModel([
            'title' => "Modification de l'axe [".$axe->getLibelle()."]",
            'form' => $form,
        ]);
        $vm->setTemplate('default/default-form');
        return $vm;
    }

    public function historiserAction() : Response
    {
        $axe = $this->getAxeService()->getRequestedAxe($this);
        $this->getAxeService()->historise($axe);

        $retour = $this->params()->fromRoute('retour');
        if ($retour) return $this->redirect()->toUrl($retour);
        return $this->redirect()->toRoute('axe', [], [], true);
    }

    public function restaurerAction() : Response
    {
        $axe = $this->getAxeService()->getRequestedAxe($this);
        $this->getAxeService()->restore($axe);

        $retour = $this->params()->fromRoute('retour');
        if ($retour) return $this->redirect()->toUrl($retour);
        return $this->redirect()->toRoute('axe', [], [], true);
    }

    public function supprimerAction() : ViewModel
    {
        $axe = $this->getAxeService()->getRequestedAxe($this);

        $request = $this->getRequest();
        if ($request->isPost()) {
            $data = $request->getPost();
            if ($data["reponse"] === "oui") $this->getAxeService()->delete($axe);
            exit();
        }

        $vm = new ViewModel();
        if ($axe !== null) {
            $vm->setTemplate('default/confirmation');
            $vm->setVariables([
                'title' => "Suppression de l'axe " . $axe->getLibelle(),
                'text' => "La suppression est définitive êtes-vous sûr&middot;e de vouloir continuer ?",
                'action' => $this->url()->fromRoute('axe/supprimer', ["axe" => $axe->getId()], [], true),
            ]);
        }
        return $vm;
    }
}
 No newline at end of file
+34 −0
Changes for module/Formation/src/Formation/Controller/AxeControllerFactory.php: 34 added lines, 0 removed lines.
Original line number Diff line number Diff line
<?php

namespace Formation\Controller;

use Formation\Form\Axe\AxeForm;
use Formation\Service\Axe\AxeService;
use Psr\Container\ContainerExceptionInterface;
use Psr\Container\ContainerInterface;
use Psr\Container\NotFoundExceptionInterface;

class AxeControllerFactory
{

    /**
     * @param ContainerInterface $container
     * @return AxeController
     * @throws ContainerExceptionInterface
     * @throws NotFoundExceptionInterface
     */
    public function __invoke(ContainerInterface $container): AxeController
    {
        /**
         * @var AxeService $axeService
         * @var AxeForm $axeForm
         */
        $axeService = $container->get(AxeService::class);
        $axeForm = $container->get('FormElementManager')->get(AxeForm::class);

        $controller = new AxeController();
        $controller->setAxeService($axeService);
        $controller->setAxeForm($axeForm);
        return $controller;
    }
}
 No newline at end of file
Loading