Commit 4f236e47 authored by David Surville's avatar David Surville
Browse files

Rattachement des rôles aux catégories de périmètre

parent 0edd1263
Loading
Loading
Loading
Loading
+124 −23
Changes for src/UnicaenUtilisateur/Entity/Db/AbstractRole.php: 124 added lines, 23 removed lines.
Original line number Diff line number Diff line
@@ -5,28 +5,80 @@ namespace UnicaenUtilisateur\Entity\Db;
use Application\Entity\Db\UtilisateurRolePerimetre;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use UnicaenPrivilege\Entity\Db\PerimetreCategorieInterface;
use UnicaenPrivilege\Entity\Db\PrivilegeInterface;

abstract class AbstractRole implements RoleInterface
{
    protected ?int $id = null;
    protected ?string $roleId = null;
    protected ?string $libelle = null;
    protected ?string $description = null;
    protected bool $default = false;
    protected bool $auto = false;
    protected ?RoleInterface $parent = null;
    protected ?string $ldapFilter = null;
    protected bool $accessibleExterieur = true;

    protected Collection $users;
    protected Collection $privileges;


    /**
     * @var int
     */
    protected $id;

    /**
     * @var string
     */
    protected $roleId;

    /**
     * @var libelle
     */
    protected $libelle;

    /**
     * @var boolean
     */
    protected $default = false;

    /**
     * @var boolean
     */
    protected $auto = false;

    /**
     * @var RoleInterface
     */
    protected $parent;

    /**
     * @var string
     */
    protected $ldapFilter;

    /**
     * @var boolean
     */
    protected $accessibleExterieur = true;

    /**
     * @var ArrayCollection
     */
    protected $users;

    /**
     * @var ArrayCollection
     */
    protected $privileges;

    /**
     * @var ArrayCollection
     */
    protected $perimetreCategories;


    /**
     * AbstractRole constructor.
     */
    public function __construct()
    {
        $this->users = new ArrayCollection();
        $this->privileges = new ArrayCollection();
        $this->perimetreCategories = new ArrayCollection();
    }

    public function __toString() : string
    {
        return $this->getLibelle();
    }

    public function getId() : ?int
@@ -128,26 +180,75 @@ abstract class AbstractRole implements RoleInterface
        });
    }

    public function getPrivileges() : Collection
    /**
     * Add privilege.
     *
     * @param PrivilegeInterface $privilege
     * @return RoleInterface
     */
    public function addPrivilege(PrivilegeInterface $privilege)
    {
        return $this->privileges;
        $this->privileges->add($privilege);

        return $this;
    }

    public function addPrivilege(PrivilegeInterface $privilege) : void
    /**
     * Remove privilege.
     *
     * @param PrivilegeInterface $privilege
     * @return RoleInterface
     */
    public function removePrivilege(PrivilegeInterface $privilege)
    {
        $this->privileges->add($privilege);
        $this->privileges->removeElement($privilege);

        return $this;
    }

    public function removePrivilege(PrivilegeInterface $privilege) : void
    /**
     * Get privileges.
     *
     * @return Collection
     */
    public function getPrivileges()
    {
        $this->privileges->removeElement($privilege);
        return $this->privileges;
    }

    /** Fonctions magiques ********************************************************************************************/
    /**
     * Add perimetre categorie.
     *
     * @param PerimetreCategorieInterface $perimetreCategorie
     * @return RoleInterface
     */
    public function addPerimetreCategorie(PerimetreCategorieInterface $perimetreCategorie)
    {
        $this->perimetreCategories->add($perimetreCategorie);

    public function __toString() : string
        return $this;
    }

    /**
     * Remove perimetre categorie.
     *
     * @param PerimetreCategorieInterface $perimetreCategorie
     * @return RoleInterface
     */
    public function removePerimetreCategorie(PerimetreCategorieInterface $perimetreCategorie)
    {
        return $this->getLibelle();
        $this->perimetreCategories->removeElement($perimetreCategorie);

        return $this;
    }

    /**
     * Get perimetre categories.
     *
     * @return Collection
     */
    public function getPerimetreCategories()
    {
        return $this->perimetreCategories;
    }
}
 No newline at end of file
+2
Changes for src/UnicaenUtilisateur/Entity/Db/Mapping/UnicaenUtilisateur.Entity.Db.Role.dcm.xml: 2 added lines, 0 removed lines.
Original line number Diff line number Diff line
@@ -39,5 +39,7 @@

        <many-to-many field="privileges" target-entity="UnicaenPrivilege\Entity\Db\Privilege" mapped-by="roles" fetch="LAZY"/>

        <many-to-many field="perimetreCategories" target-entity="UnicaenPrivilege\Entity\Db\PerimetreCategorie" mapped-by="roles" fetch="LAZY"/>

    </entity>
</doctrine-mapping>
+24
Changes for src/UnicaenUtilisateur/Entity/Db/RoleInterface.php: 24 added lines, 0 removed lines.
Original line number Diff line number Diff line
@@ -4,6 +4,7 @@ namespace UnicaenUtilisateur\Entity\Db;

use BjyAuthorize\Acl\HierarchicalRoleInterface;
use Doctrine\Common\Collections\Collection;
use UnicaenPrivilege\Entity\Db\PerimetreCategorieInterface;
use UnicaenPrivilege\Entity\Db\PrivilegeInterface;

interface RoleInterface extends HierarchicalRoleInterface
@@ -178,4 +179,27 @@ interface RoleInterface extends HierarchicalRoleInterface
     * @return RoleInterface
     */
    public function removePrivilege(PrivilegeInterface $privilege);

    /**
     * Add perimetre categorie.
     *
     * @param PerimetreCategorieInterface $perimetreCategorie
     * @return RoleInterface
     */
    public function addPerimetreCategorie(PerimetreCategorieInterface $perimetreCategorie);

    /**
     * Remove perimetre categorie.
     *
     * @param PerimetreCategorieInterface $perimetreCategorie
     * @return RoleInterface
     */
    public function removePerimetreCategorie(PerimetreCategorieInterface $perimetreCategorie);

    /**
     * Get perimetre categories.
     *
     * @return Collection
     */
    public function getPerimetreCategories();
}
 No newline at end of file