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

Nettoyage de code mort

parent 68dd907c
Loading
Loading
Loading
Loading
+0 −178
Changes for module/Application/config/merged/poste.config.php: 0 added lines, 178 removed lines.
Original line number Diff line number Diff line
<?php

namespace Application;

use Application\Controller\PosteController;
use Application\Controller\PosteControllerFactory;
use Application\Form\Poste\PosteForm;
use Application\Form\Poste\PosteFormFactory;
use Application\Form\Poste\PosteHydrator;
use Application\Form\Poste\PosteHydratorFactory;
use Application\Provider\Privilege\PostePrivileges;
use Application\Service\Poste\PosteService;
use Application\Service\Poste\PosteServiceFactory;
use Application\View\Helper\PosteViewHelper;
use UnicaenPrivilege\Guard\PrivilegeController;
use Laminas\Router\Http\Literal;
use Laminas\Router\Http\Segment;

return [
    'bjyauthorize' => [
        'guards' => [
            PrivilegeController::class => [
                [
                    'controller' => PosteController::class,
                    'action' => [
                        'index',
                    ],
                    'privileges' => [
                        PostePrivileges::POSTE_INDEX,
                    ],
                ],
                [
                    'controller' => PosteController::class,
                    'action' => [
                        'afficher',
                        'rechercher-batiment',
                    ],
                    'privileges' => [
                        PostePrivileges::POSTE_AFFICHER,
                    ],
                ],
                [
                    'controller' => PosteController::class,
                    'action' => [
                        'ajouter',
                    ],
                    'privileges' => [
                        PostePrivileges::POSTE_AJOUTER,
                    ],
                ],
                [
                    'controller' => PosteController::class,
                    'action' => [
                        'modifier',
                    ],
                    'privileges' => [
                        PostePrivileges::POSTE_EDITER,
                    ],
                ],
                [
                    'controller' => PosteController::class,
                    'action' => [
                        'supprimer',
                    ],
                    'privileges' => [
                        PostePrivileges::POSTE_EFFACER,
                    ],
                ],
            ],
        ],
    ],

//    'navigation' => [
//        'default' => [
//            'home' => [
//                'pages' => [
//                    'gestion' => [
//                        'pages' => [
//                            [
//                                'order' => 1200,
//                                'label' => 'Postes',
//                                'route' => 'poste',
//                                'resource' => PrivilegeController::getResourceId(PosteController::class, 'index') ,
//                            ],
//                        ],
//                    ],
//                ],
//            ],
//        ],
//    ],

    'router'          => [
        'routes' => [
            'poste' => [
                'type'  => Literal::class,
                'options' => [
                    'route'    => '/poste',
                    'defaults' => [
                        'controller' => PosteController::class,
                        'action'     => 'index',
                    ],
                ],
                'may_terminate' => true,
                'child_routes' => [
                    'modifier' => [
                        'type'  => Segment::class,
                        'options' => [
                            'route'    => '/modifier/:poste',
                            'defaults' => [
                                'controller' => PosteController::class,
                                'action'     => 'modifier',
                            ],
                        ],
                    ],
                    'supprimer' => [
                        'type'  => Segment::class,
                        'options' => [
                            'route'    => '/supprimer/:poste',
                            'defaults' => [
                                'controller' => PosteController::class,
                                'action'     => 'supprimer',
                            ],
                        ],
                    ],
                    'ajouter' => [
                        'type'  => Literal::class,
                        'options' => [
                            'route'    => '/ajouter',
                            'defaults' => [
                                'controller' => PosteController::class,
                                'action'     => 'ajouter',
                            ],
                        ],
                    ],
                    'afficher' => [
                        'type'  => Segment::class,
                        'options' => [
                            'route'    => '/afficher/:poste',
                            'defaults' => [
                                'controller' => PosteController::class,
                                'action'     => 'afficher',
                            ],
                        ],
                    ],
                ],
            ],
        ],
    ],

    'service_manager' => [
        'invokables' => [
        ],
        'factories' => [
            PosteService::class => PosteServiceFactory::class,
        ],
    ],
    'controllers'     => [
        'factories' => [
            PosteController::class => PosteControllerFactory::class,
        ],
    ],
    'form_elements' => [
        'factories' => [
            PosteForm::class => PosteFormFactory::class,
        ],
    ],
    'hydrators' => [
        'factories' => [
            PosteHydrator::class => PosteHydratorFactory::class,
        ]
    ],
    'view_helpers' => [
        'invokables' => [
            'poste' => PosteViewHelper::class,
        ],
    ],

];
 No newline at end of file
+0 −1
Changes for module/Application/config/module.config.php: 0 added lines, 1 removed line.
Original line number Diff line number Diff line
@@ -77,7 +77,6 @@ return [
                        FormationPrivileges::FORMATION_ACCES,
                        ActivitePrivileges::ACTIVITE_INDEX,
                        MissionspecifiquePrivileges::MISSIONSPECIFIQUE_INDEX,
                        PostePrivileges::POSTE_INDEX,
                        StructurePrivileges::STRUCTURE_INDEX,
                    ],
                ],
+0 −121
Changes for module/Application/src/Application/Controller/PosteController.php: 0 added lines, 121 removed lines.
Original line number Diff line number Diff line
<?php

namespace Application\Controller;

use Application\Entity\Db\Poste;
use Application\Form\Poste\PosteForm;
use Application\Form\Poste\PosteFormAwareTrait;
use Application\Service\Poste\PosteServiceAwareTrait;
use Laminas\Http\Request;
use Laminas\Mvc\Controller\AbstractActionController;
use Laminas\View\Model\ViewModel;

class PosteController extends AbstractActionController {
    use PosteServiceAwareTrait;
    use PosteFormAwareTrait;

    public function indexAction() : ViewModel
    {
        $postes = $this->getPosteService()->getPostes();
        
        return new ViewModel([
            'postes' => $postes,
        ]);
    }

    public function afficherAction()  :ViewModel
    {
        /** @var Poste $poste */
        $posteId = $this->params()->fromRoute('poste');
        $poste = $this->getPosteService()->getPoste($posteId);

        return new ViewModel([
            'title' => 'Affichage du poste',
            'poste' => $poste,
        ]);
    }

    public function ajouterAction() : ViewModel
    {
        /** @var Poste $poste */
        $poste = new Poste();

        /** @var PosteForm $form */
        $form = $this->getPosteForm();
        $form->setAttribute('action', $this->url()->fromRoute('poste/ajouter', [], [], true));
        $form->bind($poste);

        /** @var Request $request */
        $request = $this->getRequest();
        if ($request->isPost()) {
            $data = $request->getPost();
            $form->setData($data);
            if ($form->isValid()) {
                $this->getPosteService()->create($poste);
            }
        }

        $vm = new ViewModel();
        $vm->setTemplate('application/default/default-form');
        $vm->setVariables([
            'title' => "Ajouter un poste",
            'form' => $form,
        ]);
        return $vm;
    }

    public function modifierAction() : ViewModel
    {
        /** @var Poste $poste */
        $posteId = $this->params()->fromRoute('poste');
        $poste = $this->getPosteService()->getPoste($posteId);

        /** @var PosteForm $form */
        $form = $this->getPosteForm();
        $form->setAttribute('action', $this->url()->fromRoute('poste/modifier', ['poste' => $poste->getId()], [], true));
        $form->bind($poste);

        /** @var Request $request */
        $request = $this->getRequest();
        if ($request->isPost()) {
            $data = $request->getPost();
            $form->setData($data);
            if ($form->isValid()) {
                $this->getPosteService()->update($poste);
            }
        }

        $vm = new ViewModel();
        $vm->setTemplate('application/default/default-form');
        $vm->setVariables([
            'title' => "Modifier un poste",
            'form' => $form,
        ]);
        return $vm;
    }

    public function supprimerAction() : ViewModel
    {
        $posteId = $this->params()->fromRoute('poste');
        $poste = $this->getPosteService()->getPoste($posteId);

        /** @var Request $request */
        $request = $this->getRequest();
        if ($request->isPost()) {
            $data = $request->getPost();
            if ($data["reponse"] === "oui") $this->getPosteService()->delete($poste);
            exit();
        }

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

namespace Application\Controller;

use Application\Form\Poste\PosteForm;
use Application\Service\Poste\PosteService;
use Interop\Container\ContainerInterface;

class PosteControllerFactory {

    public function __invoke(ContainerInterface $container)
    {
        /**
         * @var PosteService $posteService
         */
        $posteService    = $container->get(PosteService::class);

        /**
         * @var PosteForm $posteForm
         */
        $posteForm = $container->get('FormElementManager')->get(PosteForm::class);

        /** @var PosteController $controller */
        $controller = new PosteController();
        $controller->setPosteService($posteService);
        $controller->setPosteForm($posteForm);
        return $controller;
    }
}
 No newline at end of file
+0 −15
Changes for module/Application/src/Application/Provider/Privilege/PostePrivileges.php: 0 added lines, 15 removed lines.
Original line number Diff line number Diff line
<?php

namespace Application\Provider\Privilege;


use UnicaenPrivilege\Provider\Privilege\Privileges;

class PostePrivileges extends Privileges
{
    const POSTE_INDEX             = 'poste-poste_index';
    const POSTE_AFFICHER          = 'poste-poste_afficher';
    const POSTE_AJOUTER           = 'poste-poste_ajouter';
    const POSTE_EDITER            = 'poste-poste_editer';
    const POSTE_EFFACER           = 'poste-poste_effacer';
}
 No newline at end of file
Loading