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

[Fix] : AgentAffichageAssertion était mal déclarée

parent 28cb63ff
Loading
Loading
Loading
Loading
+2 −1
Original line number Diff line number Diff line
@@ -10,6 +10,7 @@ Version 3.2.1 (10/05/2023)
- Formulaire de saisie des chaînes hiérarchiques pour un agent
- Correction de la modale de convocation qui ne fermait plus
- Utilisation d'un paramètre pour les temoins d'affectation pour la liste des agents passant un EP
- [Fix] : AgentAffichageAssertion était mal déclarée

---

+1 −0
Original line number Diff line number Diff line
@@ -221,6 +221,7 @@ return [
                        'options' => [
                            'route'    => '/rechercher-large',
                            'defaults' => [
                                /** @see AgentController::rechercherLargeAction() */
                                'controller' => AgentController::class,
                                'action'     => 'rechercher-large',
                            ],
+14 −1
Original line number Diff line number Diff line
@@ -12,6 +12,8 @@ use Application\Service\AgentSuperieur\AgentSuperieurServiceAwareTrait;
use Structure\Provider\Role\RoleProvider as StructureRoleProvider;
use Structure\Service\Structure\StructureServiceAwareTrait;
use UnicaenPrivilege\Assertion\AbstractAssertion;
use UnicaenPrivilege\Service\Privilege\PrivilegeCategorieServiceAwareTrait;
use UnicaenPrivilege\Service\Privilege\PrivilegeServiceAwareTrait;
use UnicaenUtilisateur\Service\User\UserServiceAwareTrait;
use Laminas\Permissions\Acl\Resource\ResourceInterface;

@@ -26,7 +28,10 @@ class AgentAffichageAssertion extends AbstractAssertion
    use StructureServiceAwareTrait;
    use UserServiceAwareTrait;

    protected function assertEntity(ResourceInterface $entity = null, $privilege = null): bool
    use PrivilegeCategorieServiceAwareTrait;
    use PrivilegeServiceAwareTrait;

    public function assertEntity(ResourceInterface $entity = null, $privilege = null): bool
    {
        if (!$entity instanceof Agent) {
            return false;
@@ -37,6 +42,14 @@ class AgentAffichageAssertion extends AbstractAssertion
        $agent = $this->getAgentService()->getAgentByUser($user);
        $role = $this->getUserService()->getConnectedRole();

        //todo QUESTION : pourquoi devoir faire cela c'est pas normal !!!
        [$catCode, $priCode] = explode('-', $privilege);
        $categorie = $this->getPrivilegeCategorieService()->findByCode($catCode);
        $pprivilege = $this->getPrivilegeService()->findByCode($priCode, $categorie->getId());
        $listings = $pprivilege->getRoles()->toArray();
        if (!in_array($role, $listings)) return false;
        //todo FIN BIZARERIE ...

        $structures = [];
        foreach ($entity->getAffectations() as $affectation) {
            $structures[] = $affectation->getStructure();
+14 −3
Original line number Diff line number Diff line
@@ -10,6 +10,9 @@ use Interop\Container\ContainerInterface;
use Psr\Container\ContainerExceptionInterface;
use Psr\Container\NotFoundExceptionInterface;
use Structure\Service\Structure\StructureService;
use UnicaenPrivilege\Service\Privilege\PrivilegeCategorieService;
use UnicaenPrivilege\Service\Privilege\PrivilegeService;
use UnicaenPrivilege\Service\Privilege\PrivilegeServiceAwareTrait;
use UnicaenUtilisateur\Service\User\UserService;
use Laminas\Mvc\Application;

@@ -21,7 +24,7 @@ class AgentAffichageAssertionFactory {
     * @throws ContainerExceptionInterface
     * @throws NotFoundExceptionInterface
     */
    public function  __invoke(ContainerInterface $container): AgentAssertion
    public function  __invoke(ContainerInterface $container): AgentAffichageAssertion
    {
        /**
         * @var AgentService $agentService
@@ -30,6 +33,9 @@ class AgentAffichageAssertionFactory {
         * @var AgentAffectationService $agentAffectationService
         * @var StructureService $structureService
         * @var UserService $userService
         *
         * @var PrivilegeService $privilegeService
         * @var PrivilegeCategorieService $categorieService
         */
        $agentService = $container->get(AgentService::class);
        $agentAutoriteService = $container->get(AgentAutoriteService::class);
@@ -38,8 +44,10 @@ class AgentAffichageAssertionFactory {
        $structureService = $container->get(StructureService::class);
        $userService = $container->get(UserService::class);

        /** @var AgentAssertion $assertion */
        $assertion = new AgentAssertion();
        $privilegeService = $container->get(PrivilegeService::class);
        $categorieService = $container->get(PrivilegeCategorieService::class);

        $assertion = new AgentAffichageAssertion();
        $assertion->setAgentService($agentService);
        $assertion->setAgentAutoriteService($agentAutoriteService);
        $assertion->setAgentSuperieurService($agentSuperieurService);
@@ -47,6 +55,9 @@ class AgentAffichageAssertionFactory {
        $assertion->setStructureService($structureService);
        $assertion->setUserService($userService);

        $assertion->setPrivilegeService($privilegeService);
        $assertion->setPrivilegeCategorieService($categorieService);

        /* @var $application Application */
        $application = $container->get('Application');
        $mvcEvent    = $application->getMvcEvent();
+2 −4
Original line number Diff line number Diff line
@@ -301,11 +301,8 @@ class AgentController extends AbstractActionController
        return $vm;
    }

    //TODO fix that ...
    public function revoquerElementAction() : Response
    {
        $retour = $this->params()->fromQuery('retour');

        $validation = $this->getValidationInstanceService()->getRequestedValidationInstance($this);
        $this->getValidationInstanceService()->historise($validation);

@@ -318,8 +315,9 @@ class AgentController extends AbstractActionController
            throw new RuntimeException("Un problème est survenue lors de l'enregistrement en base.");
        }

        $retour = $this->params()->fromQuery('retour');
        if ($retour !== null) return $this->redirect()->toUrl($retour);
        return $this->redirect()->toRoute('agent/afficher', ['agent' => $entity->getAgent()->getId()], [], true);
        return $this->redirect()->toRoute('home', [],[], true);
    }

    /** Fichier associé à l'agent *************************************************************************************/
Loading