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

Merge branch 'affectation' into development

parents a9ff2c31 766e62aa
Loading
Loading
Loading
Loading
+129 −0
Changes for module/Application/config/merged/affectation.config.php: 129 added lines, 0 removed lines.
Original line number Diff line number Diff line
<?php

namespace Application;

use Application\Controller\Affectation\AffectationController;
use Application\Controller\Affectation\AffectationControllerFactory;
use Application\Form\Affectation\AffectationForm;
use Application\Form\Affectation\AffectationFormFactory;
use Application\Form\Affectation\AffectationHydrator;
use Application\Provider\Privilege\AffectationPrivileges;
use UnicaenAuth\Guard\PrivilegeController;
use Zend\Mvc\Router\Http\Literal;
use Zend\Mvc\Router\Http\Segment;

return [
    'bjyauthorize' => [
        'guards' => [
            PrivilegeController::class => [
                [
                    'controller' => AffectationController::class,
                    'action' => [
                        'index',
                    ],
                    'privileges' => [
                        AffectationPrivileges::AFFICHER,
                    ],
                ],
                [
                    'controller' => AffectationController::class,
                    'action' => [
                        'creer',
                    ],
                    'privileges' => [
                        AffectationPrivileges::AJOUTER,
                    ],
                ],
                [
                    'controller' => AffectationController::class,
                    'action' => [
                        'editer',
                    ],
                    'privileges' => [
                        AffectationPrivileges::EDITER,
                    ],
                ],
                [
                    'controller' => AffectationController::class,
                    'action' => [
                        'effacer',
                    ],
                    'privileges' => [
                        AffectationPrivileges::EFFACER,
                    ],
                ],
            ],
        ],
    ],

    'router'          => [
        'routes' => [
            'affectation' => [
                'type'  => Literal::class,
                'options' => [
                    'route'    => '/affectation',
                    'defaults' => [
                        'controller' => AffectationController::class,
                        'action'     => 'index',
                    ],
                ],
                'may_terminate' => true,
                'child_routes' => [
                    'editer' => [
                        'type'  => Segment::class,
                        'options' => [
                            'route'    => '/editer/:id',
                            'defaults' => [
                                'controller' => AffectationController::class,
                                'action'     => 'editer',
                            ],
                        ],
                    ],
                    'effacer' => [
                        'type'  => Segment::class,
                        'options' => [
                            'route'    => '/effacer/:id',
                            'defaults' => [
                                'controller' => AffectationController::class,
                                'action'     => 'effacer',
                            ],
                        ],
                    ],
                    'creer' => [
                        'type'  => Literal::class,
                        'options' => [
                            'route'    => '/creer',
                            'defaults' => [
                                'controller' => AffectationController::class,
                                'action'     => 'creer',
                            ],
                        ],
                    ]
                ],
            ],
        ],
    ],

    'service_manager' => [
        'invokables' => [
        ],
        'factories' => [
        ],
    ],
    'controllers'     => [
        'factories' => [
            AffectationController::class => AffectationControllerFactory::class,
        ],
    ],
    'form_elements' => [
        'factories' => [
            AffectationForm::class => AffectationFormFactory::class,
        ],
    ],
    'hydrators' => [
        'invokable' => [
            AffectationHydrator::class => AffectationHydrator::class,
        ]
    ]

];
 No newline at end of file
+8 −0
Changes for module/Application/config/merged/menu.config.php: 8 added lines, 0 removed lines.
Original line number Diff line number Diff line
@@ -3,6 +3,7 @@
namespace Application;

use Application\Provider\Privilege\ActivitePrivileges;
use Application\Provider\Privilege\AffectationPrivileges;
use Application\Provider\Privilege\FicheMetierPrivileges;

return [
@@ -38,6 +39,13 @@ return [
                                'dropdown-header' => true,
                                'icon' => 'fas fa-angle-right'
                            ],
                            [
                                'label' => 'Les affectations',
                                'route' => 'affectation',
                                'privileges' => AffectationPrivileges::AFFICHER,
                                'dropdown-header' => true,
                                'icon' => 'fas fa-angle-right'
                            ],
                        ],
                    ],
                ],
+6 −0
Changes for module/Application/config/module.config.php: 6 added lines, 0 removed lines.
Original line number Diff line number Diff line
@@ -77,6 +77,9 @@ return [
    ],

    'view_manager'    => [
        'template_map'             => [
            'layout/layout' => __DIR__ . '/../view/layout/layout.phtml',
        ],
        'template_path_stack' => [
            __DIR__ . '/../view',
        ],
@@ -109,5 +112,8 @@ return [
            '113_' => 'https://gest.unicaen.fr/public/bootstrap-select-1.9.4/dist/css/bootstrap-select.min.css',
            '121_' => 'vendor/vakata-jstree-3.3.4/dist/themes/proton/style.min.css',
        ],
        'images' => [
            '100_' => 'img/PrEECoG.svg',
        ]
    ],
];
+85 −0
Changes for module/Application/src/Application/Controller/Affectation/AffectationController.php: 85 added lines, 0 removed lines.
Original line number Diff line number Diff line
<?php

namespace Application\Controller\Affectation;

use Application\Entity\Db\Affectation;
use Application\Form\Affectation\AffectationForm;
use Application\Service\Affectation\AffectationAwareServiceTrait;
use Zend\Http\Request;
use Zend\Mvc\Controller\AbstractActionController;
use Zend\View\Model\ViewModel;

class AffectationController extends AbstractActionController {
    use AffectationAwareServiceTrait;

    public function indexAction()
    {
        $affectations = $this->getAffectationService()->getAffections();
        return new ViewModel([
            'affectations' => $affectations,
        ]);
    }

    public function creerAction()
    {
        /** @var Affectation $affectation */
        $affectation = new Affectation();

        /** @var AffectationForm $form */
        $form = $this->getServiceLocator()->get('FormElementManager')->get(AffectationForm::class);
//        $form->setAttribute('action', $this->url()->fromRoute('activite/creer',[],[], true));
        $form->bind($affectation);
        /** @var Request $request */
        $request = $this->getRequest();
        if ($request->isPost()) {
            $data = $request->getPost();
            $form->setData($data);

            if ($form->isValid()) {
                $this->getAffectationService()->create($affectation);
                $this->redirect()->toRoute('affectation');
            }
        }

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

    public function editerAction()
    {
        /** @var Affectation $affectation */
        $affectationId = $this->params()->fromRoute('id');
        $affectation = $this->getAffectationService()->getAffectation($affectationId);

        /** @var AffectationForm $form */
        $form = $this->getServiceLocator()->get('FormElementManager')->get(AffectationForm::class);
//        $form->setAttribute('action', $this->url()->fromRoute('activite/editer',['id' => $activite->getId()],[], true));
        $form->bind($affectation);
        /** @var Request $request */
        $request = $this->getRequest();
        if ($request->isPost()) {
            $data = $request->getPost();
            $form->setData($data);

            if ($form->isValid()) {
                $this->getAffectationService()->update($affectation);
                $this->redirect()->toRoute('affectation');
            }
        }

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

    public function effacerAction()
    {
        /** @var Affectation $affectation */
        $affectationId = $this->params()->fromRoute('id');
        $affectation = $this->getAffectationService()->getAffectation($affectationId);

        $this->getAffectationService()->delete($affectation);
        $this->redirect()->toRoute('affectation');
    }
}
 No newline at end of file
+20 −0
Changes for module/Application/src/Application/Controller/Affectation/AffectationControllerFactory.php: 20 added lines, 0 removed lines.
Original line number Diff line number Diff line
<?php

namespace Application\Controller\Affectation;

use Application\Service\Affectation\AffectationService;
use Zend\Mvc\Controller\ControllerManager;

class AffectationControllerFactory {

    public function __invoke(ControllerManager $controllerManager)
    {
        /** @var AffectationService $affectationService */
        $affectationService = $controllerManager->getServiceLocator()->get(AffectationService::class);

        /** @var AffectationController $controller */
        $controller = new AffectationController();
        $controller->setAffectationService($affectationService);
        return $controller;
    }
}
 No newline at end of file
Loading