Loading src/UnicaenUtilisateur/Entity/Db/AbstractRole.php +163 −28 Changes for src/UnicaenUtilisateur/Entity/Db/AbstractRole.php: 163 added lines, 28 removed lines. Original line number Diff line number Diff line Loading @@ -3,6 +3,8 @@ namespace UnicaenUtilisateur\Entity\Db; use Doctrine\Common\Collections\ArrayCollection; use Doctrine\Common\Collections\Collection; use UnicaenPrivilege\Entity\Db\PrivilegeInterface; abstract class AbstractRole implements RoleInterface { Loading @@ -16,10 +18,20 @@ abstract class AbstractRole implements RoleInterface */ protected $roleId; /** * @var libelle */ protected $libelle; /** * @var boolean */ protected $default = false; /** * @var boolean */ protected $isDefault = false; protected $auto = false; /** * @var Role Loading @@ -31,11 +43,22 @@ abstract class AbstractRole implements RoleInterface */ protected $ldapFilter; /** * @var boolean */ protected $accessibleExterieur = true; /** * @var ArrayCollection */ protected $users; /** * @var ArrayCollection */ protected $privileges; /** * AbstractRole constructor. */ Loading @@ -45,7 +68,15 @@ abstract class AbstractRole implements RoleInterface } /** * Get the id. * @return string */ public function __toString() { return $this->getRoleId(); } /** * Get id. * * @return int */ Loading @@ -55,11 +86,10 @@ abstract class AbstractRole implements RoleInterface } /** * Set the id. * Set id. * * @param int $id * * @return self * @return RoleInterface */ public function setId($id) { Loading @@ -69,7 +99,7 @@ abstract class AbstractRole implements RoleInterface } /** * Get the role id. * Get roleId. * * @return string */ Loading @@ -79,11 +109,10 @@ abstract class AbstractRole implements RoleInterface } /** * Set the role id. * Set roleId. * * @param string $roleId * * @return self * @return RoleInterface */ public function setRoleId($roleId) { Loading @@ -92,26 +121,93 @@ abstract class AbstractRole implements RoleInterface return $this; } /** * Get libelle. * * @return string */ public function getLibelle() { return $this->libelle; } /** * Set libelle. * * @param string|null $libelle * @return RoleInterface */ public function setLibelle($libelle) { $this->libelle = $libelle; return $this; } /** * Is this role the default one ? * * @return boolean */ public function getIsDefault() public function isDefault() { return $this->isDefault; return $this->default; } /** * Set this role as the default one. * * @param boolean $isDefault * @param boolean $default * @return RoleInterface */ public function setDefault($default) { $this->default = (boolean)$default; return $this; } /** * Is auto ? * * @return self * @return boolean */ public function setIsDefault($isDefault) public function isAuto() { $this->isDefault = (boolean)$isDefault; return $this->auto; } /** * Set auto. * * @param boolean $auto * @return RoleInterface */ public function setAuto($auto) { $this->auto = $auto; return $this; } /** * Is accessible from the outside ? * * @return boolean */ public function isAccessibleExterieur() { return $this->accessibleExterieur; } /** * Set accessible from the outside. * * @param boolean $accessibleExterieur * @return RoleInterface */ public function setAccessibleExterieur($accessibleExterieur) { $this->accessibleExterieur = $accessibleExterieur; return $this; } Loading @@ -119,7 +215,7 @@ abstract class AbstractRole implements RoleInterface /** * Get the parent role * * @return Role * @return RoleInterface */ public function getParent() { Loading @@ -129,9 +225,8 @@ abstract class AbstractRole implements RoleInterface /** * Set the parent role. * * @param RoleInterface $parent * * @return self * @param RoleInterface|null $parent * @return RoleInterface */ public function setParent(RoleInterface $parent = null) { Loading @@ -141,6 +236,8 @@ abstract class AbstractRole implements RoleInterface } /** * Get ldapFilter. * * @return string */ public function getLdapFilter() Loading @@ -149,9 +246,10 @@ abstract class AbstractRole implements RoleInterface } /** * @param string $ldapFilter * Set ldapFilter. * * @return Role * @param string $ldapFilter * @return RoleInterface */ public function setLdapFilter($ldapFilter) { Loading @@ -163,35 +261,72 @@ abstract class AbstractRole implements RoleInterface /** * Get users. * * @return array * @return Collection */ public function getUsers() { return $this->users->getValues(); return $this->users; } /** * {@inheritdoc} * Add user. * * @param UserInterface $user * @return RoleInterface */ public function addUser(UserInterface $user) { $this->users[] = $user; $this->users->add($user); return $this; } /** * Remove user. * * @param UserInterface $user * @return RoleInterface */ public function removeUser(UserInterface $user) { $this->users->removeElement($user); return $this; } /** * Get privileges. * * @return string * @return Collection */ public function __toString() public function getPrivileges() { return $this->getRoleId(); return $this->privileges; } /** * 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; } } No newline at end of file src/UnicaenUtilisateur/Entity/Db/AbstractUser.php +86 −26 Changes for src/UnicaenUtilisateur/Entity/Db/AbstractUser.php: 86 added lines, 26 removed lines. Original line number Diff line number Diff line Loading @@ -47,19 +47,33 @@ abstract class AbstractUser implements UserInterface, ProviderInterface, Recherc */ protected $passwordResetToken; /** * @var RoleInterface */ private $lastRole; /** * @var ArrayCollection */ protected $roles; /** * Initialies the roles variable. * AbstractUser constructor. */ public function __construct() { $this->roles = new ArrayCollection(); } /** * @return string */ public function __toString(): string { return (string)$this->getDisplayName(); } /** * Get id. * Loading @@ -74,7 +88,7 @@ abstract class AbstractUser implements UserInterface, ProviderInterface, Recherc * Set id. * * @param int $id * @return self * @return UserInterface */ public function setId($id) { Loading @@ -97,7 +111,7 @@ abstract class AbstractUser implements UserInterface, ProviderInterface, Recherc * Set username. * * @param string $username * @return self * @return UserInterface */ public function setUsername($username) { Loading @@ -119,8 +133,8 @@ abstract class AbstractUser implements UserInterface, ProviderInterface, Recherc /** * Set email. * * @param string $email * @return self * @param string|null $email * @return UserInterface */ public function setEmail($email) { Loading @@ -132,7 +146,7 @@ abstract class AbstractUser implements UserInterface, ProviderInterface, Recherc /** * Get displayName. * * @return string * @return string|null */ public function getDisplayName() { Loading @@ -142,8 +156,8 @@ abstract class AbstractUser implements UserInterface, ProviderInterface, Recherc /** * Set displayName. * * @param string $displayName * @return self * @param string|null $displayName * @return UserInterface */ public function setDisplayName($displayName) { Loading @@ -166,7 +180,7 @@ abstract class AbstractUser implements UserInterface, ProviderInterface, Recherc * Set password. * * @param string $password * @return self * @return UserInterface */ public function setPassword($password) { Loading @@ -189,7 +203,7 @@ abstract class AbstractUser implements UserInterface, ProviderInterface, Recherc * Set state. * * @param int $state * @return self * @return UserInterface */ public function setState($state) { Loading @@ -199,7 +213,9 @@ abstract class AbstractUser implements UserInterface, ProviderInterface, Recherc } /** * @return string * Get passwordResetToken. * * @return string|null */ public function getPasswordResetToken() { Loading @@ -207,10 +223,12 @@ abstract class AbstractUser implements UserInterface, ProviderInterface, Recherc } /** * @param string $passwordResetToken * @return self * Set passwordResetToken. * * @param string|null $passwordResetToken * @return UserInterface */ public function setPasswordResetToken($passwordResetToken = null) public function setPasswordResetToken($passwordResetToken) { $this->passwordResetToken = $passwordResetToken; Loading @@ -218,7 +236,30 @@ abstract class AbstractUser implements UserInterface, ProviderInterface, Recherc } /** * Get role. * Get lastRole. * * @return RoleInterface|null */ public function getLastRole() { return $this->lastRole; } /** * Set lastRole. * * @param RoleInterface|null $lastRole * @return UserInterface */ public function setLastRole(?RoleInterface $lastRole) { $this->lastRole = $lastRole; return $this; } /** * Get roles of user * * @return Collection */ Loading @@ -228,10 +269,10 @@ abstract class AbstractUser implements UserInterface, ProviderInterface, Recherc } /** * Add a role to the user. * Add a role to user. * * @param RoleInterface $role * @return self * @return UserInterface */ public function addRole(RoleInterface $role) { Loading @@ -240,6 +281,34 @@ abstract class AbstractUser implements UserInterface, ProviderInterface, Recherc return $this; } /** * Remove a role to user. * * @param $role * @return UserInterface */ public function removeRole(RoleInterface $role) { $this->roles->removeElement($role); return $this; } /** * Check user role * * @param RoleInterface $role * @return bool */ function hasRole(RoleInterface $role) { foreach ($this->roles as $r) { if ($r === $role) return true; } return false; } /** * Retourne true si cet utilisateur est local. * Loading @@ -255,13 +324,4 @@ abstract class AbstractUser implements UserInterface, ProviderInterface, Recherc AbstractUser::PASSWORD_SHIB, ]); } /** * * @return string */ public function __toString() { return (string)$this->getDisplayName(); } } No newline at end of file src/UnicaenUtilisateur/Entity/Db/Mapping/UnicaenUtilisateur.Entity.Db.Role.dcm.xml +28 −20 Changes for src/UnicaenUtilisateur/Entity/Db/Mapping/UnicaenUtilisateur.Entity.Db.Role.dcm.xml: 28 added lines, 20 removed lines. Original line number Diff line number Diff line <?xml version="1.0" encoding="utf-8"?> <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"> <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"> <id name="id" type="integer" column="id"> <indexes> <index name="ix_role_parent" columns="PARENT_ID"/> </indexes> <unique-constraints> <unique-constraint name="un_role_role" columns="ROLE_ID"/> </unique-constraints> <id name="id" type="integer" column="ID"> <generator strategy="IDENTITY"/> </id> <field name="roleId" type="string" column="role_id" length="64" nullable="false"/> <field name="libelle" type="string" column="libelle" length="64" nullable="false"/> <field name="isDefault" type="boolean" column="is_default" nullable="false"/> <field name="auto" type="boolean" column="is_auto" nullable="false"/> <field name="ldapFilter" type="string" column="ldap_filter" length="255" nullable="true"/> <field name="roleId" type="string" column="ROLE_ID" length="64" nullable="false"/> <field name="libelle" type="string" column="LIBELLE" length="64" nullable="false"/> <field name="default" type="boolean" column="IS_DEFAULT" nullable="false"/> <field name="auto" type="boolean" column="IS_AUTO" nullable="false"/> <field name="ldapFilter" type="string" column="LDAP_FILTER" length="255" nullable="true"/> <field name="accessibleExterieur" type="integer" column="ACCESSIBLE_EXTERIEUR" nullable="false"/> <many-to-many field="users" target-entity="UnicaenUtilisateur\Entity\Db\User" inversed-by="roles" fetch="LAZY"> <join-table name="unicaen_utilisateur_role_linker"> <many-to-one field="parent" target-entity="UnicaenUtilisateur\Entity\Db\Role" fetch="LAZY"> <join-columns> <join-column name="role_id" referenced-column-name="id"/> <join-column name="PARENT_ID" referenced-column-name="ID"/> </join-columns> <inverse-join-columns> <join-column name="user_id" referenced-column-name="id"/> </inverse-join-columns> </join-table> </many-to-many> </many-to-one> <many-to-many field="users" target-entity="UnicaenUtilisateur\Entity\Db\User" mapped-by="roles" fetch="LAZY"/> <many-to-many field="privilege" target-entity="UnicaenPrivilege\Entity\Db\Privilege" inversed-by="role" fetch="LAZY"> <join-table name="unicaen_utilisateur_privilege_linker"> <many-to-many field="privileges" target-entity="UnicaenPrivilege\Entity\Db\Privilege" inversed-by="roles" fetch="LAZY"> <join-table name="UNICAEN_PRIVILEGE_PRIVILEGE_ROLE_LINKER"> <join-columns> <join-column name="role_id" referenced-column-name="id"/> <join-column name="ROLE_ID" referenced-column-name="ID"/> </join-columns> <inverse-join-columns> <join-column name="privilege_id" referenced-column-name="id"/> <join-column name="PRIVILEGE_ID" referenced-column-name="ID"/> </inverse-join-columns> </join-table> </many-to-many> Loading src/UnicaenUtilisateur/Entity/Db/Mapping/UnicaenUtilisateur.Entity.Db.User.dcm.xml +30 −16 Changes for src/UnicaenUtilisateur/Entity/Db/Mapping/UnicaenUtilisateur.Entity.Db.User.dcm.xml: 30 added lines, 16 removed lines. Original line number Diff line number Diff line <?xml version="1.0" encoding="utf-8"?> <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\User" table="unicaen_utilisateur_user"> <id name="id" type="integer" column="id"> <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\User" table="UNICAEN_UTILISATEUR_USER"> <indexes> <index name="ix_user_last_role" columns="LAST_ROLE_ID"/> </indexes> <unique-constraints> <unique-constraint name="un_user_username" columns="USERNAME"/> <unique-constraint name="un_user_password_reset_token" columns="PASSWORD_RESET_TOKEN"/> </unique-constraints> <id name="id" type="integer" column="ID"> <generator strategy="IDENTITY"/> </id> <field name="username" type="string" length="255" column="username" nullable="false"/> <field name="displayName" type="string" length="64" column="display_name" nullable="false"/> <field name="email" type="string" length="255" column="email" nullable="true"/> <field name="password" type="string" length="128" column="password" nullable="false"/> <field name="passwordResetToken" type="string" length="256" column="password_reset_token" nullable="true"/> <field name="state" type="boolean" column="state" nullable="false"/> <field name="username" type="string" column="USERNAME" length="255" nullable="false"/> <field name="email" type="string" column="EMAIL" length="255" nullable="true"/> <field name="displayName" type="string" column="DISPLAY_NAME" length="64" nullable="true"/> <field name="password" type="string" column="PASSWORD" length="128" nullable="false"/> <field name="state" type="int" column="STATE" nullable="false"/> <field name="passwordResetToken" type="string" column="PASSWORD_RESET_TOKEN" length="256" nullable="true"/> <many-to-one field="lastRole" target-entity="UnicaenUtilisateur\Entity\Db\Role" fetch="LAZY"> <join-columns> <join-column name="LAST_ROLE_ID" referenced-column-name="ID"/> </join-columns> </many-to-one> <many-to-many field="roles" target-entity="UnicaenUtilisateur\Entity\Db\Role" inversed-by="users" fetch="LAZY"> <join-table name="unicaen_utilisateur_role_linker"> <join-table name="UNICAEN_UTILISATEUR_ROLE_LINKER"> <join-columns> <join-column name="user_id" referenced-column-name="id"/> <join-column name="USER_ID" referenced-column-name="ID"/> </join-columns> <inverse-join-columns> <join-column name="role_id" referenced-column-name="id"/> <join-column name="ROLE_ID" referenced-column-name="ID"/> </inverse-join-columns> </join-table> </many-to-many> <many-to-one target-entity="UnicaenUtilisateur\Entity\Db\Role" field="lastRole"> <join-column name="last_role_id" referenced-column-name="id"/> </many-to-one> </entity> </doctrine-mapping> src/UnicaenUtilisateur/Entity/Db/Role.php +1 −107 Changes for src/UnicaenUtilisateur/Entity/Db/Role.php: 1 added line, 107 removed lines. Original line number Diff line number Diff line Loading @@ -6,111 +6,5 @@ use Doctrine\Common\Collections\ArrayCollection; use Doctrine\Common\Collections\Collection; use UnicaenPrivilege\Entity\Db\Privilege; class Role extends AbstractRole { /** @var boolean */ private $auto; /** @var string */ private $libelle; /** @var Collection (Privilege)*/ private $privilege; public function __construct() { parent::__construct(); $this->privilege = new ArrayCollection(); } /** * @param UserInterface $user * @return Collection */ public function addUser(UserInterface $user) { $this->users[] = $user; return $this->users; } /** * @param UserInterface $user * @return Collection */ public function removeUser(UserInterface $user) { $this->users->removeElement($user); return $this->users; } /** * @return Collection */ public function getUsers() { return $this->users; } /** * @param Privilege $privilege * @return Role */ public function addPrivilege(Privilege $privilege) { $this->privilege[] = $privilege; return $this; } /** * @param Privilege $privilege */ public function removePrivilege(Privilege $privilege) { $this->privilege->removeElement($privilege); } /** * @return Collection */ public function getPrivileges() { return $this->privilege; } /** * @return string */ public function getLibelle() { return $this->libelle; } /** * @param string|null $libelle * @return Role */ public function setLibelle(?string $libelle) { $this->libelle = $libelle; return $this; } /** * @return bool */ public function isAuto(): bool { if ($this->auto === null) return false; return $this->auto; } /** * @param bool $auto * @return Role */ public function setAuto(bool $auto): Role { $this->auto = $auto; return $this; } } class Role extends AbstractRole {} Loading
src/UnicaenUtilisateur/Entity/Db/AbstractRole.php +163 −28 Changes for src/UnicaenUtilisateur/Entity/Db/AbstractRole.php: 163 added lines, 28 removed lines. Original line number Diff line number Diff line Loading @@ -3,6 +3,8 @@ namespace UnicaenUtilisateur\Entity\Db; use Doctrine\Common\Collections\ArrayCollection; use Doctrine\Common\Collections\Collection; use UnicaenPrivilege\Entity\Db\PrivilegeInterface; abstract class AbstractRole implements RoleInterface { Loading @@ -16,10 +18,20 @@ abstract class AbstractRole implements RoleInterface */ protected $roleId; /** * @var libelle */ protected $libelle; /** * @var boolean */ protected $default = false; /** * @var boolean */ protected $isDefault = false; protected $auto = false; /** * @var Role Loading @@ -31,11 +43,22 @@ abstract class AbstractRole implements RoleInterface */ protected $ldapFilter; /** * @var boolean */ protected $accessibleExterieur = true; /** * @var ArrayCollection */ protected $users; /** * @var ArrayCollection */ protected $privileges; /** * AbstractRole constructor. */ Loading @@ -45,7 +68,15 @@ abstract class AbstractRole implements RoleInterface } /** * Get the id. * @return string */ public function __toString() { return $this->getRoleId(); } /** * Get id. * * @return int */ Loading @@ -55,11 +86,10 @@ abstract class AbstractRole implements RoleInterface } /** * Set the id. * Set id. * * @param int $id * * @return self * @return RoleInterface */ public function setId($id) { Loading @@ -69,7 +99,7 @@ abstract class AbstractRole implements RoleInterface } /** * Get the role id. * Get roleId. * * @return string */ Loading @@ -79,11 +109,10 @@ abstract class AbstractRole implements RoleInterface } /** * Set the role id. * Set roleId. * * @param string $roleId * * @return self * @return RoleInterface */ public function setRoleId($roleId) { Loading @@ -92,26 +121,93 @@ abstract class AbstractRole implements RoleInterface return $this; } /** * Get libelle. * * @return string */ public function getLibelle() { return $this->libelle; } /** * Set libelle. * * @param string|null $libelle * @return RoleInterface */ public function setLibelle($libelle) { $this->libelle = $libelle; return $this; } /** * Is this role the default one ? * * @return boolean */ public function getIsDefault() public function isDefault() { return $this->isDefault; return $this->default; } /** * Set this role as the default one. * * @param boolean $isDefault * @param boolean $default * @return RoleInterface */ public function setDefault($default) { $this->default = (boolean)$default; return $this; } /** * Is auto ? * * @return self * @return boolean */ public function setIsDefault($isDefault) public function isAuto() { $this->isDefault = (boolean)$isDefault; return $this->auto; } /** * Set auto. * * @param boolean $auto * @return RoleInterface */ public function setAuto($auto) { $this->auto = $auto; return $this; } /** * Is accessible from the outside ? * * @return boolean */ public function isAccessibleExterieur() { return $this->accessibleExterieur; } /** * Set accessible from the outside. * * @param boolean $accessibleExterieur * @return RoleInterface */ public function setAccessibleExterieur($accessibleExterieur) { $this->accessibleExterieur = $accessibleExterieur; return $this; } Loading @@ -119,7 +215,7 @@ abstract class AbstractRole implements RoleInterface /** * Get the parent role * * @return Role * @return RoleInterface */ public function getParent() { Loading @@ -129,9 +225,8 @@ abstract class AbstractRole implements RoleInterface /** * Set the parent role. * * @param RoleInterface $parent * * @return self * @param RoleInterface|null $parent * @return RoleInterface */ public function setParent(RoleInterface $parent = null) { Loading @@ -141,6 +236,8 @@ abstract class AbstractRole implements RoleInterface } /** * Get ldapFilter. * * @return string */ public function getLdapFilter() Loading @@ -149,9 +246,10 @@ abstract class AbstractRole implements RoleInterface } /** * @param string $ldapFilter * Set ldapFilter. * * @return Role * @param string $ldapFilter * @return RoleInterface */ public function setLdapFilter($ldapFilter) { Loading @@ -163,35 +261,72 @@ abstract class AbstractRole implements RoleInterface /** * Get users. * * @return array * @return Collection */ public function getUsers() { return $this->users->getValues(); return $this->users; } /** * {@inheritdoc} * Add user. * * @param UserInterface $user * @return RoleInterface */ public function addUser(UserInterface $user) { $this->users[] = $user; $this->users->add($user); return $this; } /** * Remove user. * * @param UserInterface $user * @return RoleInterface */ public function removeUser(UserInterface $user) { $this->users->removeElement($user); return $this; } /** * Get privileges. * * @return string * @return Collection */ public function __toString() public function getPrivileges() { return $this->getRoleId(); return $this->privileges; } /** * 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; } } No newline at end of file
src/UnicaenUtilisateur/Entity/Db/AbstractUser.php +86 −26 Changes for src/UnicaenUtilisateur/Entity/Db/AbstractUser.php: 86 added lines, 26 removed lines. Original line number Diff line number Diff line Loading @@ -47,19 +47,33 @@ abstract class AbstractUser implements UserInterface, ProviderInterface, Recherc */ protected $passwordResetToken; /** * @var RoleInterface */ private $lastRole; /** * @var ArrayCollection */ protected $roles; /** * Initialies the roles variable. * AbstractUser constructor. */ public function __construct() { $this->roles = new ArrayCollection(); } /** * @return string */ public function __toString(): string { return (string)$this->getDisplayName(); } /** * Get id. * Loading @@ -74,7 +88,7 @@ abstract class AbstractUser implements UserInterface, ProviderInterface, Recherc * Set id. * * @param int $id * @return self * @return UserInterface */ public function setId($id) { Loading @@ -97,7 +111,7 @@ abstract class AbstractUser implements UserInterface, ProviderInterface, Recherc * Set username. * * @param string $username * @return self * @return UserInterface */ public function setUsername($username) { Loading @@ -119,8 +133,8 @@ abstract class AbstractUser implements UserInterface, ProviderInterface, Recherc /** * Set email. * * @param string $email * @return self * @param string|null $email * @return UserInterface */ public function setEmail($email) { Loading @@ -132,7 +146,7 @@ abstract class AbstractUser implements UserInterface, ProviderInterface, Recherc /** * Get displayName. * * @return string * @return string|null */ public function getDisplayName() { Loading @@ -142,8 +156,8 @@ abstract class AbstractUser implements UserInterface, ProviderInterface, Recherc /** * Set displayName. * * @param string $displayName * @return self * @param string|null $displayName * @return UserInterface */ public function setDisplayName($displayName) { Loading @@ -166,7 +180,7 @@ abstract class AbstractUser implements UserInterface, ProviderInterface, Recherc * Set password. * * @param string $password * @return self * @return UserInterface */ public function setPassword($password) { Loading @@ -189,7 +203,7 @@ abstract class AbstractUser implements UserInterface, ProviderInterface, Recherc * Set state. * * @param int $state * @return self * @return UserInterface */ public function setState($state) { Loading @@ -199,7 +213,9 @@ abstract class AbstractUser implements UserInterface, ProviderInterface, Recherc } /** * @return string * Get passwordResetToken. * * @return string|null */ public function getPasswordResetToken() { Loading @@ -207,10 +223,12 @@ abstract class AbstractUser implements UserInterface, ProviderInterface, Recherc } /** * @param string $passwordResetToken * @return self * Set passwordResetToken. * * @param string|null $passwordResetToken * @return UserInterface */ public function setPasswordResetToken($passwordResetToken = null) public function setPasswordResetToken($passwordResetToken) { $this->passwordResetToken = $passwordResetToken; Loading @@ -218,7 +236,30 @@ abstract class AbstractUser implements UserInterface, ProviderInterface, Recherc } /** * Get role. * Get lastRole. * * @return RoleInterface|null */ public function getLastRole() { return $this->lastRole; } /** * Set lastRole. * * @param RoleInterface|null $lastRole * @return UserInterface */ public function setLastRole(?RoleInterface $lastRole) { $this->lastRole = $lastRole; return $this; } /** * Get roles of user * * @return Collection */ Loading @@ -228,10 +269,10 @@ abstract class AbstractUser implements UserInterface, ProviderInterface, Recherc } /** * Add a role to the user. * Add a role to user. * * @param RoleInterface $role * @return self * @return UserInterface */ public function addRole(RoleInterface $role) { Loading @@ -240,6 +281,34 @@ abstract class AbstractUser implements UserInterface, ProviderInterface, Recherc return $this; } /** * Remove a role to user. * * @param $role * @return UserInterface */ public function removeRole(RoleInterface $role) { $this->roles->removeElement($role); return $this; } /** * Check user role * * @param RoleInterface $role * @return bool */ function hasRole(RoleInterface $role) { foreach ($this->roles as $r) { if ($r === $role) return true; } return false; } /** * Retourne true si cet utilisateur est local. * Loading @@ -255,13 +324,4 @@ abstract class AbstractUser implements UserInterface, ProviderInterface, Recherc AbstractUser::PASSWORD_SHIB, ]); } /** * * @return string */ public function __toString() { return (string)$this->getDisplayName(); } } No newline at end of file
src/UnicaenUtilisateur/Entity/Db/Mapping/UnicaenUtilisateur.Entity.Db.Role.dcm.xml +28 −20 Changes for src/UnicaenUtilisateur/Entity/Db/Mapping/UnicaenUtilisateur.Entity.Db.Role.dcm.xml: 28 added lines, 20 removed lines. Original line number Diff line number Diff line <?xml version="1.0" encoding="utf-8"?> <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"> <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"> <id name="id" type="integer" column="id"> <indexes> <index name="ix_role_parent" columns="PARENT_ID"/> </indexes> <unique-constraints> <unique-constraint name="un_role_role" columns="ROLE_ID"/> </unique-constraints> <id name="id" type="integer" column="ID"> <generator strategy="IDENTITY"/> </id> <field name="roleId" type="string" column="role_id" length="64" nullable="false"/> <field name="libelle" type="string" column="libelle" length="64" nullable="false"/> <field name="isDefault" type="boolean" column="is_default" nullable="false"/> <field name="auto" type="boolean" column="is_auto" nullable="false"/> <field name="ldapFilter" type="string" column="ldap_filter" length="255" nullable="true"/> <field name="roleId" type="string" column="ROLE_ID" length="64" nullable="false"/> <field name="libelle" type="string" column="LIBELLE" length="64" nullable="false"/> <field name="default" type="boolean" column="IS_DEFAULT" nullable="false"/> <field name="auto" type="boolean" column="IS_AUTO" nullable="false"/> <field name="ldapFilter" type="string" column="LDAP_FILTER" length="255" nullable="true"/> <field name="accessibleExterieur" type="integer" column="ACCESSIBLE_EXTERIEUR" nullable="false"/> <many-to-many field="users" target-entity="UnicaenUtilisateur\Entity\Db\User" inversed-by="roles" fetch="LAZY"> <join-table name="unicaen_utilisateur_role_linker"> <many-to-one field="parent" target-entity="UnicaenUtilisateur\Entity\Db\Role" fetch="LAZY"> <join-columns> <join-column name="role_id" referenced-column-name="id"/> <join-column name="PARENT_ID" referenced-column-name="ID"/> </join-columns> <inverse-join-columns> <join-column name="user_id" referenced-column-name="id"/> </inverse-join-columns> </join-table> </many-to-many> </many-to-one> <many-to-many field="users" target-entity="UnicaenUtilisateur\Entity\Db\User" mapped-by="roles" fetch="LAZY"/> <many-to-many field="privilege" target-entity="UnicaenPrivilege\Entity\Db\Privilege" inversed-by="role" fetch="LAZY"> <join-table name="unicaen_utilisateur_privilege_linker"> <many-to-many field="privileges" target-entity="UnicaenPrivilege\Entity\Db\Privilege" inversed-by="roles" fetch="LAZY"> <join-table name="UNICAEN_PRIVILEGE_PRIVILEGE_ROLE_LINKER"> <join-columns> <join-column name="role_id" referenced-column-name="id"/> <join-column name="ROLE_ID" referenced-column-name="ID"/> </join-columns> <inverse-join-columns> <join-column name="privilege_id" referenced-column-name="id"/> <join-column name="PRIVILEGE_ID" referenced-column-name="ID"/> </inverse-join-columns> </join-table> </many-to-many> Loading
src/UnicaenUtilisateur/Entity/Db/Mapping/UnicaenUtilisateur.Entity.Db.User.dcm.xml +30 −16 Changes for src/UnicaenUtilisateur/Entity/Db/Mapping/UnicaenUtilisateur.Entity.Db.User.dcm.xml: 30 added lines, 16 removed lines. Original line number Diff line number Diff line <?xml version="1.0" encoding="utf-8"?> <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\User" table="unicaen_utilisateur_user"> <id name="id" type="integer" column="id"> <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\User" table="UNICAEN_UTILISATEUR_USER"> <indexes> <index name="ix_user_last_role" columns="LAST_ROLE_ID"/> </indexes> <unique-constraints> <unique-constraint name="un_user_username" columns="USERNAME"/> <unique-constraint name="un_user_password_reset_token" columns="PASSWORD_RESET_TOKEN"/> </unique-constraints> <id name="id" type="integer" column="ID"> <generator strategy="IDENTITY"/> </id> <field name="username" type="string" length="255" column="username" nullable="false"/> <field name="displayName" type="string" length="64" column="display_name" nullable="false"/> <field name="email" type="string" length="255" column="email" nullable="true"/> <field name="password" type="string" length="128" column="password" nullable="false"/> <field name="passwordResetToken" type="string" length="256" column="password_reset_token" nullable="true"/> <field name="state" type="boolean" column="state" nullable="false"/> <field name="username" type="string" column="USERNAME" length="255" nullable="false"/> <field name="email" type="string" column="EMAIL" length="255" nullable="true"/> <field name="displayName" type="string" column="DISPLAY_NAME" length="64" nullable="true"/> <field name="password" type="string" column="PASSWORD" length="128" nullable="false"/> <field name="state" type="int" column="STATE" nullable="false"/> <field name="passwordResetToken" type="string" column="PASSWORD_RESET_TOKEN" length="256" nullable="true"/> <many-to-one field="lastRole" target-entity="UnicaenUtilisateur\Entity\Db\Role" fetch="LAZY"> <join-columns> <join-column name="LAST_ROLE_ID" referenced-column-name="ID"/> </join-columns> </many-to-one> <many-to-many field="roles" target-entity="UnicaenUtilisateur\Entity\Db\Role" inversed-by="users" fetch="LAZY"> <join-table name="unicaen_utilisateur_role_linker"> <join-table name="UNICAEN_UTILISATEUR_ROLE_LINKER"> <join-columns> <join-column name="user_id" referenced-column-name="id"/> <join-column name="USER_ID" referenced-column-name="ID"/> </join-columns> <inverse-join-columns> <join-column name="role_id" referenced-column-name="id"/> <join-column name="ROLE_ID" referenced-column-name="ID"/> </inverse-join-columns> </join-table> </many-to-many> <many-to-one target-entity="UnicaenUtilisateur\Entity\Db\Role" field="lastRole"> <join-column name="last_role_id" referenced-column-name="id"/> </many-to-one> </entity> </doctrine-mapping>
src/UnicaenUtilisateur/Entity/Db/Role.php +1 −107 Changes for src/UnicaenUtilisateur/Entity/Db/Role.php: 1 added line, 107 removed lines. Original line number Diff line number Diff line Loading @@ -6,111 +6,5 @@ use Doctrine\Common\Collections\ArrayCollection; use Doctrine\Common\Collections\Collection; use UnicaenPrivilege\Entity\Db\Privilege; class Role extends AbstractRole { /** @var boolean */ private $auto; /** @var string */ private $libelle; /** @var Collection (Privilege)*/ private $privilege; public function __construct() { parent::__construct(); $this->privilege = new ArrayCollection(); } /** * @param UserInterface $user * @return Collection */ public function addUser(UserInterface $user) { $this->users[] = $user; return $this->users; } /** * @param UserInterface $user * @return Collection */ public function removeUser(UserInterface $user) { $this->users->removeElement($user); return $this->users; } /** * @return Collection */ public function getUsers() { return $this->users; } /** * @param Privilege $privilege * @return Role */ public function addPrivilege(Privilege $privilege) { $this->privilege[] = $privilege; return $this; } /** * @param Privilege $privilege */ public function removePrivilege(Privilege $privilege) { $this->privilege->removeElement($privilege); } /** * @return Collection */ public function getPrivileges() { return $this->privilege; } /** * @return string */ public function getLibelle() { return $this->libelle; } /** * @param string|null $libelle * @return Role */ public function setLibelle(?string $libelle) { $this->libelle = $libelle; return $this; } /** * @return bool */ public function isAuto(): bool { if ($this->auto === null) return false; return $this->auto; } /** * @param bool $auto * @return Role */ public function setAuto(bool $auto): Role { $this->auto = $auto; return $this; } } class Role extends AbstractRole {}