Commit d0ce7175 authored by David Surville's avatar David Surville
Browse files

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

parent d4827f7d
Loading
Loading
Loading
Loading
+52 −8
Changes for src/UnicaenUtilisateur/Entity/Db/AbstractRole.php: 52 added lines, 8 removed lines.
Original line number Diff line number Diff line
@@ -5,6 +5,7 @@ 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
@@ -59,6 +60,11 @@ abstract class AbstractRole implements RoleInterface
     */
    protected $privileges;

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


    /**
     * AbstractRole constructor.
@@ -66,6 +72,8 @@ abstract class AbstractRole implements RoleInterface
    public function __construct()
    {
        $this->users = new ArrayCollection();
        $this->privileges = new ArrayCollection();
        $this->perimetreCategories = new ArrayCollection();
    }

    /**
@@ -272,6 +280,32 @@ abstract class AbstractRole implements RoleInterface
        });
    }

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

        return $this;
    }

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

        return $this;
    }

    /**
     * Get privileges.
     *
@@ -283,28 +317,38 @@ abstract class AbstractRole implements RoleInterface
    }

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

        return $this;
    }

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

        return $this;
    }

    /**
     * Get perimetre categories.
     *
     * @return Collection
     */
    public function getPerimetreCategories()
    {
        return $this->perimetreCategories;
    }
}
 No newline at end of file
+2 −0
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
@@ -38,5 +38,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 −0
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
@@ -162,4 +163,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