Commit 9754dc45 authored by Bertrand Gauthier's avatar Bertrand Gauthier
Browse files

Utilisation de These::getActeurSorted().

parent f5498be6
Loading
Loading
Loading
Loading
+15 −15
Changes for module/Application/src/Application/Controller/RoleController.php: 15 added lines, 15 removed lines.
Original line number Diff line number Diff line
@@ -25,19 +25,19 @@ class RoleController extends AbstractController {
        ]);
    }

    public function incrementerOrdreAction() {
        $idRole = $this->params()->fromRoute('role');
        $role = $this->getRoleService()->getRepository()->find($idRole);
        $this->getRoleService()->incrementerOrdre($role);

        $this->redirect()->toRoute('role-ordre');
    }

    public function decrementerOrdreAction() {
        $idRole = $this->params()->fromRoute('role');
        $role = $this->getRoleService()->getRepository()->find($idRole);
        $this->getRoleService()->decrementerOrdre($role);

        $this->redirect()->toRoute('role-ordre');
    }
//    public function incrementerOrdreAction() {
//        $idRole = $this->params()->fromRoute('role');
//        $role = $this->getRoleService()->getRepository()->find($idRole);
//        $this->getRoleService()->incrementerOrdre($role);
//
//        $this->redirect()->toRoute('role-ordre');
//    }
//
//    public function decrementerOrdreAction() {
//        $idRole = $this->params()->fromRoute('role');
//        $role = $this->getRoleService()->getRepository()->find($idRole);
//        $this->getRoleService()->decrementerOrdre($role);
//
//        $this->redirect()->toRoute('role-ordre');
//    }
}
 No newline at end of file
+1 −1
Changes for module/Application/src/Application/Service/Fichier/FichierService.php: 1 added line, 1 removed line.
Original line number Diff line number Diff line
@@ -568,7 +568,7 @@ class FichierService extends BaseService
        }

        $acteursEnCouverture = $acteurs;
        usort($acteursEnCouverture, function(Acteur $a1, Acteur $a2) {return $a1->getRole()->getOrdreAffichage() < $a2->getRole()->getOrdreAffichage();});
        usort($acteursEnCouverture, Acteur::getComparisonFunction());
        $acteursEnCouverture = array_unique($acteursEnCouverture);

        /** @var Acteur $rapporteur */
+13 −30
Changes for module/Application/src/Application/Service/Role/RoleService.php: 13 added lines, 30 removed lines.
Original line number Diff line number Diff line
@@ -263,34 +263,17 @@ class RoleService extends BaseService
        return $result;
    }

    /**
     * @param Role $role
     * @return Role
     */
    public function incrementerOrdre($role)
    {
        $role->setOrdreAffichage($role->getOrdreAffichage() + 1);
        try {
            $this->getEntityManager()->flush($role);
        } catch (OptimisticLockException $e) {
            throw new RuntimeException("Problème lors du change de l'ordre d'affichage du rôle [".$role->getId()."]");
        }
        return $role;
    }

    /**
     * @param Role $role
     * @return Role
     */
    public function decrementerOrdre($role)
    {
        $role->setOrdreAffichage(max($role->getOrdreAffichage() -1, 0));
        try {
            $this->getEntityManager()->flush($role);
        } catch (OptimisticLockException $e) {
            throw new RuntimeException("Problème lors du change de l'ordre d'affichage du rôle [".$role->getId()."]");
        }
        return $role;
    }

//    /**
//     * @param Role $role
//     * @return Role
//     */
//    public function updateRole($role)
//    {
//        try {
//            $this->getEntityManager()->flush($role);
//        } catch (OptimisticLockException $e) {
//            throw new RuntimeException("Problème lors du change de l'ordre d'affichage du rôle [".$role->getId()."]");
//        }
//        return $role;
//    }
}
 No newline at end of file
−8
Changes for module/Application/view/application/role/index.phtml: 0 added lines, 8 removed lines.
Original line number Diff line number Diff line
@@ -40,14 +40,6 @@ use Application\Entity\Db\Role;
                    <td> <?php echo $role->getCode(); ?> </td>
                    <td> <?php echo $role->getLibelle(); ?> </td>
                    <td> <?php echo $role->getOrdreAffichage(); ?> </td>
                    <td>
                        <a href="<?php echo $this->url('role-ordre/incrementer', ['role' => $role->getId()], [], true); ?>">
                            <span class="glyphicon glyphicon-arrow-up"></span>
                        </a>
                        <a href="<?php echo $this->url('role-ordre/decrementer', ['role' => $role->getId()], [], true); ?>">
                            <span class="glyphicon glyphicon-arrow-down"></span>
                        </a>
                    </td>
                </tr>
            <?php endforeach; ?>
        </tbody>