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

Correction de la gestion des liens avec les rôles

parent f8138133
Loading
Loading
Loading
Loading
Loading
+4 −1
Original line number Diff line number Diff line
@@ -2,7 +2,10 @@
<doctrine-mapping xmlns="http://doctrine-project.org/schemas/orm/doctrine-mapping"
                  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
                  xsi:schemaLocation="http://doctrine-project.org/schemas/orm/doctrine-mapping http://doctrine-project.org/schemas/orm/doctrine-mapping.xsd">
    <entity name="UnicaenUtilisateur\Entity\Db\Role" table="UNICAEN_UTILISATEUR_ROLE">
    <entity name="UnicaenUtilisateur\Entity\Db\Role"
            table="UNICAEN_UTILISATEUR_ROLE"
            repository-class="UnicaenUtilisateur\Entity\Db\Repository\RoleRepository"
    >

        <indexes>
            <index name="ix_role_parent" columns="PARENT_ID"/>
+14 −4
Original line number Diff line number Diff line
<?php

namespace UnicaenPrivilege\Entity\Db\Repository;
namespace UnicaenUtilisateur\Entity\Db\Repository;

use Doctrine\ORM\EntityRepository;
use Doctrine\ORM\QueryBuilder;
use UnicaenApp\Service\EntityManagerAwareTrait;

class PrivilegeRepository extends EntityRepository
class RoleRepository extends EntityRepository
{
    use EntityManagerAwareTrait;

@@ -14,8 +14,18 @@ class PrivilegeRepository extends EntityRepository
    {
        $qb = parent::createQueryBuilder($alias, $indexBy);
        $qb
            ->leftjoin($alias . '.roles', 'role')->addSelect('role')
            ->leftJoin($alias . '.categorie', 'categorie')->addSelect('categorie');
            ->leftjoin($alias . '.privileges', 'privilege')->addSelect('privilege')
            ->leftJoin('privilege.categorie', 'categorie')->addSelect('categorie')
        ;
        return $qb;
    }

    public function find($id, $lockMode = null, $lockVersion = null)
    {
        $qb = $this->createQueryBuilder('role')
            ->andWhere('role.id = :id')->setParameter('id', $id);
        $result = $qb->getQuery()->getOneOrNullResult();
        return $result;
    }

}
 No newline at end of file
+5 −4
Original line number Diff line number Diff line
@@ -3,6 +3,7 @@
namespace UnicaenUtilisateur\Service\Role;

use Doctrine\ORM\EntityRepository;
use Doctrine\ORM\NonUniqueResultException;
use Doctrine\ORM\ORMException;
use InvalidArgumentException;
use Laminas\Mvc\Controller\AbstractActionController;
@@ -78,18 +79,18 @@ class RoleService

    /**
     * @param string $roleId
     * @return RoleInterface
     * @return RoleInterface|null
     */
    public function findByRoleId(string $roleId)
    public function findByRoleId(string $roleId) : ?RoleInterface
    {
        return $this->getRepo()->findOneBy(['roleId' => $roleId]);
    }

    /**
     * @param string $libelle
     * @return RoleInterface
     * @return RoleInterface|null
     */
    public function findByLibelle(string $libelle)
    public function findByLibelle(string $libelle) : ?RoleInterface
    {
        return $this->getRepo()->findOneBy(['libelle' => $libelle]);
    }
+1 −0
Original line number Diff line number Diff line
@@ -28,6 +28,7 @@ class RoleServiceFactory
        $service->setEntityManager($entityManager);
        $service->setRoleEntityClass($config['unicaen-auth']['role_entity_class'] ?? Role::class);


        return $service;
    }
}
 No newline at end of file