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

Ajout des thèmes de formation

parent fee41fbe
Loading
Loading
Loading
Loading
+86 −0
Changes for module/Application/config/merged/formation.config.php: 86 added lines, 0 removed lines.
Original line number Diff line number Diff line
@@ -8,6 +8,10 @@ use Application\Form\Formation\FormationForm;
use Application\Form\Formation\FormationFormFactory;
use Application\Form\Formation\FormationHydrator;
use Application\Form\Formation\FormationHydratorFactory;
use Application\Form\FormationTheme\FormationThemeForm;
use Application\Form\FormationTheme\FormationThemeFormFactory;
use Application\Form\FormationTheme\FormationThemeHydrator;
use Application\Form\FormationTheme\FormationThemeHydratorFactory;
use Application\Provider\Privilege\FormationPrivileges;
use Application\Service\Formation\FormationService;
use Application\Service\Formation\FormationServiceFactory;
@@ -24,6 +28,8 @@ return [
                    'action' => [
                        'index',
                        'afficher',

                        'afficher-theme',
                    ],
                    'privileges' => [
                        FormationPrivileges::AFFICHER,
@@ -36,6 +42,11 @@ return [
                        'editer',
                        'historiser',
                        'restaurer',

                        'ajouter-theme',
                        'editer-theme',
                        'historiser-theme',
                        'restaurer-theme',
                    ],
                    'privileges' => [
                        FormationPrivileges::EDITER,
@@ -45,6 +56,7 @@ return [
                    'controller' => FormationController::class,
                    'action' => [
                        'detruire',
                        'detruire-theme',
                    ],
                    'privileges' => [
                        FormationPrivileges::DETRUIRE,
@@ -56,6 +68,78 @@ return [

    'router'          => [
        'routes' => [
            'formation-theme' => [
                'type'  => Literal::class,
                'options' => [
                    'route'    => '/formation-theme',
                    'defaults' => [
                        'controller' => FormationController::class,
                    ],
                ],
                'may_terminate' => false,
                'child_routes' => [
                    'afficher' => [
                        'type'  => Segment::class,
                        'options' => [
                            'route'    => '/afficher/:formation-theme',
                            'defaults' => [
                                'controller' => FormationController::class,
                                'action'     => 'afficher-theme',
                            ],
                        ],
                    ],
                    'ajouter' => [
                        'type'  => Literal::class,
                        'options' => [
                            'route'    => '/ajouter',
                            'defaults' => [
                                'controller' => FormationController::class,
                                'action'     => 'ajouter-theme',
                            ],
                        ],
                    ],
                    'editer' => [
                        'type'  => Segment::class,
                        'options' => [
                            'route'    => '/editer/:formation-theme',
                            'defaults' => [
                                'controller' => FormationController::class,
                                'action'     => 'editer-theme',
                            ],
                        ],
                    ],
                    'historiser' => [
                        'type'  => Segment::class,
                        'options' => [
                            'route'    => '/historiser/:formation-theme',
                            'defaults' => [
                                'controller' => FormationController::class,
                                'action'     => 'historiser-theme',
                            ],
                        ],
                    ],
                    'restaurer' => [
                        'type'  => Segment::class,
                        'options' => [
                            'route'    => '/restaurer/:formation-theme',
                            'defaults' => [
                                'controller' => FormationController::class,
                                'action'     => 'restaurer-theme',
                            ],
                        ],
                    ],
                    'detruire' => [
                        'type'  => Segment::class,
                        'options' => [
                            'route'    => '/detruire/:formation-theme',
                            'defaults' => [
                                'controller' => FormationController::class,
                                'action'     => 'detruire-theme',
                            ],
                        ],
                    ],
                ],
            ],
            'formation' => [
                'type'  => Literal::class,
                'options' => [
@@ -145,11 +229,13 @@ return [
    'form_elements' => [
        'factories' => [
            FormationForm::class => FormationFormFactory::class,
            FormationThemeForm::class => FormationThemeFormFactory::class,
        ],
    ],
    'hydrators' => [
        'factories' => [
            FormationHydrator::class => FormationHydratorFactory::class,
            FormationThemeHydrator::class => FormationThemeHydratorFactory::class,
        ],
    ]

+1 −4
Changes for module/Application/config/module.config.php: 1 added line, 4 removed lines.
Original line number Diff line number Diff line
@@ -113,12 +113,10 @@ return [

    'public_files' => [
        'inline_scripts' => [
            '100_' => 'js/jquery.ui.datepicker-fr.js',
//            '111_' => 'https://gest.unicaen.fr/public/bootstrap-confirmation-2.4.0/bootstrap-confirmation.min.js',
//            '100_' => 'js/jquery.ui.datepicker-fr.js',
            '111_' => 'vendor/DataTables-1.10.18/datatables.min.js',
            '112_' => 'vendor/font-awesome-5.0.9/fontawesome-all.min.js',
            '114_' => 'vendor/bootstrap-select-1.13.2/dist/js/bootstrap-select.min.js',
            '124_' => 'vendor/vakata-jstree-3.3.4/dist/jstree.min.js',
            '150_' => 'js/tinymce/js/tinymce/tinymce.js',
            '151_' => 'js/form_fiche.js',
        ],
@@ -127,7 +125,6 @@ return [
//            '111_' => 'https://gest.unicaen.fr/public/open-sans-gh-pages/open-sans.css',
            '111_' => 'vendor/DataTables-1.10.18/datatables.min.css',
            '114_' => 'vendor/bootstrap-select-1.13.2/dist/css/bootstrap-select.min.css',
            '121_' => 'vendor/vakata-jstree-3.3.4/dist/themes/proton/style.min.css',
        ],
        'images' => [
            '100_' => 'img/PrEECoG.svg',
+89 −0
Changes for module/Application/src/Application/Controller/FormationController.php: 89 added lines, 0 removed lines.
Original line number Diff line number Diff line
@@ -3,7 +3,9 @@
namespace Application\Controller;

use Application\Entity\Db\Formation;
use Application\Entity\Db\FormationTheme;
use Application\Form\Formation\FormationFormAwareTrait;
use Application\Form\FormationTheme\FormationThemeFormAwareTrait;
use Application\Service\Formation\FormationServiceAwareTrait;
use Zend\Http\Request;
use Zend\Mvc\Controller\AbstractActionController;
@@ -13,12 +15,15 @@ class FormationController extends AbstractActionController
{
    use FormationServiceAwareTrait;
    use FormationFormAwareTrait;
    use FormationThemeFormAwareTrait;

    public function indexAction()
    {
        $formations = $this->getFormationService()->getFormations('libelle');
        $themes = $this->getFormationService()->getFormationsThemes();
        return new ViewModel([
            'formations' => $formations,
            'themes' => $themes,
        ]);
    }

@@ -108,4 +113,88 @@ class FormationController extends AbstractActionController
        return $this->redirect()->toRoute('formation', [], [], true);
    }

    public function ajouterThemeAction()
    {
        $theme = new FormationTheme();
        $form = $this->getFormationThemeForm();
        $form->setAttribute('action', $this->url()->fromRoute('formation-theme/ajouter', [], [], true));
        $form->bind($theme);

        /** @var Request $request */
        $request = $this->getRequest();
        if ($request->isPost()) {
            $data = $request->getPost();
            $form->setData($data);
            if ($form->isValid()) {
                $this->getFormationService()->createTheme($theme);
                //return $this->redirect()->toRoute('formation', [], [], true);
            }
        }

        $vm = new ViewModel();
        $vm->setTemplate('application/default/default-form');
        $vm->setVariables([
            'title' => 'Ajouter un thème de formation',
            'form' => $form,
        ]);
        return $vm;
    }

    public function afficherThemeAction()
    {
        $theme = $this->getFormationService()->getRequestedFormationTheme($this);

        return new ViewModel([
           'title' => 'Affichage du thème',
           'theme' => $theme,
        ]);
    }

    public function editerThemeAction()
    {
        $theme = $this->getFormationService()->getRequestedFormationTheme($this);
        $form = $this->getFormationThemeForm();
        $form->setAttribute('action', $this->url()->fromRoute('formation-theme/editer', ['formation-theme' => $theme->getId()], [], true));
        $form->bind($theme);

        /** @var Request $request */
        $request = $this->getRequest();
        if ($request->isPost()) {
            $data = $request->getPost();
            $form->setData($data);
            if ($form->isValid()) {
                $this->getFormationService()->updateTheme($theme);
                //return $this->redirect()->toRoute('formation', [], [], true);
            }
        }

        $vm = new ViewModel();
        $vm->setTemplate('application/default/default-form');
        $vm->setVariables([
            'title' => 'Modifier un thème de formation',
            'form' => $form,
        ]);
        return $vm;
    }

    public function historiserThemeAction()
    {
        $theme = $this->getFormationService()->getRequestedFormationTheme($this);
        $this->getFormationService()->historizeTheme($theme);
        return $this->redirect()->toRoute('formation', [], [], true);
    }

    public function restaurerThemeAction()
    {
        $theme = $this->getFormationService()->getRequestedFormationTheme($this);
        $this->getFormationService()->restoreTheme($theme);
        return $this->redirect()->toRoute('formation', [], [], true);
    }

    public function detruireThemeAction()
    {
        $theme = $this->getFormationService()->getRequestedFormationTheme($this);
        $this->getFormationService()->deleteTheme($theme);
        return $this->redirect()->toRoute('formation', [], [], true);
    }
}
 No newline at end of file
+4 −0
Changes for module/Application/src/Application/Controller/FormationControllerFactory.php: 4 added lines, 0 removed lines.
Original line number Diff line number Diff line
@@ -3,6 +3,7 @@
namespace Application\Controller;

use Application\Form\Formation\FormationForm;
use Application\Form\FormationTheme\FormationThemeForm;
use Application\Service\Formation\FormationService;
use Interop\Container\ContainerInterface;

@@ -13,14 +14,17 @@ class FormationControllerFactory {
        /**
         * @var FormationService $formationService
         * @var FormationForm $formationForm
         * @var FormationThemeForm $formationThemeForm
         */
        $formationService = $container->get(FormationService::class);
        $formationForm = $container->get('FormElementManager')->get(FormationForm::class);
        $formationThemeForm = $container->get('FormElementManager')->get(FormationThemeForm::class);

        /** @var FormationController $controller */
        $controller = new FormationController();
        $controller->setFormationService($formationService);
        $controller->setFormationForm($formationForm);
        $controller->setFormationThemeForm($formationThemeForm);
        return $controller;
    }

+20 −0
Changes for module/Application/src/Application/Entity/Db/Formation.php: 20 added lines, 0 removed lines.
Original line number Diff line number Diff line
@@ -16,6 +16,8 @@ class Formation {
    private $description;
    /** @var string */
    private $lien;
    /** @var FormationTheme */
    private $theme;

    /** @var ArrayCollection */
    private $applications;
@@ -91,6 +93,24 @@ class Formation {
        return $this;
    }

    /**
     * @return FormationTheme
     */
    public function getTheme()
    {
        return $this->theme;
    }

    /**
     * @param FormationTheme $theme
     * @return Formation
     */
    public function setTheme($theme)
    {
        $this->theme = $theme;
        return $this;
    }

    /**
     * @return Application[]
     */
Loading