Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
lib
unicaen
auth
Commits
48d5fa7f
Commit
48d5fa7f
authored
Jul 21, 2016
by
Bertrand Gauthier
Browse files
Work in progress.
parent
c10c0124
Changes
7
Hide whitespace changes
Inline
Side-by-side
src/UnicaenAuth/Controller/DroitsController.php
View file @
48d5fa7f
...
...
@@ -2,8 +2,6 @@
namespace
UnicaenAuth\Controller
;
use
UnicaenAuth\Entity\Db\Privilege
;
use
UnicaenAuth\Entity\Db\Role
;
use
UnicaenAuth\Form\Droits\Traits\RoleFormAwareTrait
;
use
UnicaenAuth\Service\Traits\PrivilegeServiceAwareTrait
;
use
UnicaenAuth\Service\Traits\RoleServiceAwareTrait
;
...
...
src/UnicaenAuth/Entity/Db/AbstractRole.php
0 → 100644
View file @
48d5fa7f
<?php
namespace
UnicaenAuth\Entity\Db
;
use
BjyAuthorize\Acl\HierarchicalRoleInterface
;
use
Doctrine\ORM\Mapping
as
ORM
;
/**
* Role entity abstract mother class.
*
* @ORM\MappedSuperclass
*/
abstract
class
AbstractRole
implements
HierarchicalRoleInterface
{
/**
* @var int
* @ORM\Id
* @ORM\Column(type="integer")
* @ORM\GeneratedValue(strategy="AUTO")
*/
protected
$id
;
/**
* @var string
* @ORM\Column(name="role_id", type="string", length=255, unique=true, nullable=false)
*/
protected
$roleId
;
/**
* @var boolean
* @ORM\Column(name="is_default", type="boolean", nullable=true)
*/
protected
$isDefault
=
false
;
/**
* @var Role
* @ORM\ManyToOne(targetEntity="Role")
*/
protected
$parent
;
/**
* @var string
* @ORM\Column(name="ldap_filter", type="string", length=255, unique=true, nullable=true)
*/
protected
$ldapFilter
;
/**
* @var \Doctrine\Common\Collections\Collection
* @ORM\ManyToMany(targetEntity="UnicaenAuth\Entity\Db\User")
* @ORM\JoinTable(name="user_role_linker",
* joinColumns={@ORM\JoinColumn(name="user_id", referencedColumnName="id")},
* inverseJoinColumns={@ORM\JoinColumn(name="role_id", referencedColumnName="id")}
* )
*/
protected
$users
;
/**
* Get the id.
*
* @return int
*/
public
function
getId
()
{
return
$this
->
id
;
}
/**
* Set the id.
*
* @param int $id
*
* @return self
*/
public
function
setId
(
$id
)
{
$this
->
id
=
(
int
)
$id
;
return
$this
;
}
/**
* Get the role id.
*
* @return string
*/
public
function
getRoleId
()
{
return
$this
->
roleId
;
}
/**
* Set the role id.
*
* @param string $roleId
*
* @return self
*/
public
function
setRoleId
(
$roleId
)
{
$this
->
roleId
=
(
string
)
$roleId
;
return
$this
;
}
/**
* Is this role the default one ?
*
* @return boolean
*/
public
function
getIsDefault
()
{
return
$this
->
isDefault
;
}
/**
* Set this role as the default one.
*
* @param boolean $isDefault
*
* @return self
*/
public
function
setIsDefault
(
$isDefault
)
{
$this
->
isDefault
=
(
boolean
)
$isDefault
;
return
$this
;
}
/**
* Get the parent role
*
* @return Role
*/
public
function
getParent
()
{
return
$this
->
parent
;
}
/**
* Set the parent role.
*
* @param Role $role
*
* @return self
*/
public
function
setParent
(
Role
$parent
)
{
$this
->
parent
=
$parent
;
return
$this
;
}
/**
* @return string
*/
public
function
getLdapFilter
()
{
return
$this
->
ldapFilter
;
}
/**
* @param string $ldapFilter
*
* @return Role
*/
public
function
setLdapFilter
(
$ldapFilter
)
{
$this
->
ldapFilter
=
$ldapFilter
;
return
$this
;
}
/**
* Get users.
*
* @return array
*/
public
function
getUsers
()
{
return
$this
->
users
->
getValues
();
}
/**
* Add a user to the role.
*
* @param User $user
*
* @return void
*/
public
function
addUser
(
$user
)
{
$this
->
users
[]
=
$user
;
}
/**
*
* @return string
*/
public
function
__toString
()
{
return
$this
->
getRoleId
();
}
}
\ No newline at end of file
src/UnicaenAuth/Entity/Db/AbstractUser.php
View file @
48d5fa7f
...
...
@@ -6,7 +6,6 @@ use BjyAuthorize\Provider\Role\ProviderInterface;
use
Doctrine\Common\Collections\ArrayCollection
;
use
Doctrine\Common\Collections\Collection
;
use
Doctrine\ORM\Mapping
as
ORM
;
use
ZfcUser\Entity\UserInterface
;
/**
* User entity abstract mother class.
...
...
src/UnicaenAuth/Entity/Db/Role.php
View file @
48d5fa7f
...
...
@@ -12,225 +12,12 @@ use BjyAuthorize\Acl\HierarchicalRoleInterface;
use
Doctrine\ORM\Mapping
as
ORM
;
/**
*
An example entity that represents a role
.
*
User entity class
.
*
* @ORM\Entity
* @ORM\Table(name="
user_
role")
* @ORM\Table(name="
`
role
`
")
*/
class
Role
implem
en
t
s
HierarchicalRoleInterfac
e
class
Role
ext
en
d
s
AbstractRol
e
{
/**
* @var int
* @ORM\Id
* @ORM\Column(type="integer")
* @ORM\GeneratedValue(strategy="AUTO")
*/
protected
$id
;
/**
* @var string
* @ORM\Column(name="role_id", type="string", length=255, unique=true, nullable=false)
*/
protected
$roleId
;
/**
* @var boolean
* @ORM\Column(name="is_default", type="boolean", nullable=true)
*/
protected
$isDefault
=
false
;
/**
* @var Role
* @ORM\ManyToOne(targetEntity="Role")
*/
protected
$parent
;
/**
* @var string
* @ORM\Column(name="ldap_filter", type="string", length=255, unique=true, nullable=true)
*/
protected
$ldapFilter
;
/**
* @var \Doctrine\Common\Collections\Collection
* @ORM\ManyToMany(targetEntity="UnicaenAuth\Entity\Db\User")
* @ORM\JoinTable(name="user_role_linker",
* joinColumns={@ORM\JoinColumn(name="user_id", referencedColumnName="id")},
* inverseJoinColumns={@ORM\JoinColumn(name="role_id", referencedColumnName="id")}
* )
*/
protected
$users
;
/**
* Get the id.
*
* @return int
*/
public
function
getId
()
{
return
$this
->
id
;
}
/**
* Set the id.
*
* @param int $id
*
* @return self
*/
public
function
setId
(
$id
)
{
$this
->
id
=
(
int
)
$id
;
return
$this
;
}
/**
* Get the role id.
*
* @return string
*/
public
function
getRoleId
()
{
return
$this
->
roleId
;
}
/**
* Set the role id.
*
* @param string $roleId
*
* @return self
*/
public
function
setRoleId
(
$roleId
)
{
$this
->
roleId
=
(
string
)
$roleId
;
return
$this
;
}
/**
* Is this role the default one ?
*
* @return boolean
*/
public
function
getIsDefault
()
{
return
$this
->
isDefault
;
}
/**
* Set this role as the default one.
*
* @param boolean $isDefault
*
* @return self
*/
public
function
setIsDefault
(
$isDefault
)
{
$this
->
isDefault
=
(
boolean
)
$isDefault
;
return
$this
;
}
/**
* Get the parent role
*
* @return Role
*/
public
function
getParent
()
{
return
$this
->
parent
;
}
/**
* Set the parent role.
*
* @param Role $role
*
* @return self
*/
public
function
setParent
(
Role
$parent
)
{
$this
->
parent
=
$parent
;
return
$this
;
}
/**
* @return string
*/
public
function
getLdapFilter
()
{
return
$this
->
ldapFilter
;
}
/**
* @param string $ldapFilter
*
* @return Role
*/
public
function
setLdapFilter
(
$ldapFilter
)
{
$this
->
ldapFilter
=
$ldapFilter
;
return
$this
;
}
/**
* Get users.
*
* @return array
*/
public
function
getUsers
()
{
return
$this
->
users
->
getValues
();
}
/**
* Add a user to the role.
*
* @param User $user
*
* @return void
*/
public
function
addUser
(
$user
)
{
$this
->
users
[]
=
$user
;
}
/**
*
* @return string
*/
public
function
__toString
()
{
return
$this
->
getRoleId
();
}
}
\ No newline at end of file
src/UnicaenAuth/Entity/Db/RoleInterface.php
0 → 100644
View file @
48d5fa7f
<?php
namespace
UnicaenAuth\Entity\Db
;
use
BjyAuthorize\Acl\HierarchicalRoleInterface
;
use
ZfcUser\Entity\UserInterface
;
interface
RoleInterface
extends
HierarchicalRoleInterface
{
/**
* @param int $id
* @return self
*/
public
function
setId
(
$id
);
/**
* @return int
*/
public
function
getId
();
/**
* @return string
*/
public
function
getRoleId
();
/**
* @param string $roleId
* @return self
*/
public
function
setRoleId
(
$roleId
);
/**
* @return boolean
*/
public
function
getIsDefault
();
/**
* @param boolean $isDefault
* @return self
*/
public
function
setIsDefault
(
$isDefault
);
/**
* @return RoleInterface|null
*/
public
function
getParent
();
/**
* @param RoleInterface|null $parent
* @return self
*/
public
function
setParent
(
RoleInterface
$parent
=
null
);
/**
* @return string
*/
public
function
getLdapFilter
();
/**
* @param string $ldapFilter
* @return self
*/
public
function
setLdapFilter
(
$ldapFilter
);
/**
* @return UserInterface[]
*/
public
function
getUsers
();
/**
* @param UserInterface $user
* @return self
*/
public
function
addUser
(
UserInterface
$user
);
/**
* @return string
*/
public
function
__toString
();
}
\ No newline at end of file
src/UnicaenAuth/Entity/Db/UserInterface.php
0 → 100644
View file @
48d5fa7f
<?php
namespace
UnicaenAuth\Entity\Db
;
use
Doctrine\Common\Collections\Collection
;
interface
UserInterface
extends
\
ZfcUser\Entity\UserInterface
{
/**
* @return int
*/
public
function
getId
();
/**
* @param int $id
* @return self
*/
public
function
setId
(
$id
);
/**
* @return string
*/
public
function
getUsername
();
/**
* @param string $username
* @return self
*/
public
function
setUsername
(
$username
);
/**
* @return string
*/
public
function
getEmail
();
/**
* @param string $email
* @return self
*/
public
function
setEmail
(
$email
);
/**
* @return string
*/
public
function
getDisplayName
();
/**
* @param string $displayName
* @return self
*/
public
function
setDisplayName
(
$displayName
);
/**
* Get password.
*
* @return string
*/
public
function
getPassword
();
/**
* @param string $password
* @return self
*/
public
function
setPassword
(
$password
);
/**
* @return int
*/
public
function
getState
();
/**
* @param int $state