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
f6d8df4d
Commit
f6d8df4d
authored
Mar 26, 2019
by
Bertrand Gauthier
Browse files
UserMapper n'a pas besoin d'hériter de \ZfcUser\Mapper\User.
parent
f0cfcb41
Pipeline
#4156
passed with stage
in 20 seconds
Changes
1
Pipelines
1
Show whitespace changes
Inline
Side-by-side
src/UnicaenAuth/Service/UserMapper.php
View file @
f6d8df4d
...
...
@@ -5,9 +5,10 @@ namespace UnicaenAuth\Service;
use
Doctrine\ORM\EntityManagerInterface
;
use
UnicaenAuth\Entity\Db\AbstractUser
;
use
UnicaenAuth\Options\ModuleOptions
;
use
Zend\Hydrator\HydratorInterface
;
use
ZfcUser\Entity\UserInterface
as
UserEntityInterface
;
use
ZfcUser\Mapper\UserInterface
;
class
UserMapper
ext
en
d
s
\
ZfcUser\Mapper\User
class
UserMapper
implem
en
t
s
UserInterface
{
//========== repris du module zf-commons/zfc-user-doctrine-orm abandonné =========
/**
...
...
@@ -20,12 +21,21 @@ class UserMapper extends \ZfcUser\Mapper\User
*/
protected
$options
;
/**
* UserMapper constructor.
*
* @param EntityManagerInterface $em
* @param ModuleOptions $options
*/
public
function
__construct
(
EntityManagerInterface
$em
,
ModuleOptions
$options
)
{
$this
->
em
=
$em
;
$this
->
options
=
$options
;
}
/**
* {@inheritdoc}
*/
public
function
findByEmail
(
$email
)
{
$er
=
$this
->
em
->
getRepository
(
$this
->
options
->
getUserEntityClass
());
...
...
@@ -33,6 +43,9 @@ class UserMapper extends \ZfcUser\Mapper\User
return
$er
->
findOneBy
(
array
(
'email'
=>
$email
));
}
/**
* {@inheritdoc}
*/
public
function
findByUsername
(
$username
)
{
$er
=
$this
->
em
->
getRepository
(
$this
->
options
->
getUserEntityClass
());
...
...
@@ -40,6 +53,9 @@ class UserMapper extends \ZfcUser\Mapper\User
return
$er
->
findOneBy
(
array
(
'username'
=>
$username
));
}
/**
* {@inheritdoc}
*/
public
function
findById
(
$id
)
{
$er
=
$this
->
em
->
getRepository
(
$this
->
options
->
getUserEntityClass
());
...
...
@@ -50,7 +66,7 @@ class UserMapper extends \ZfcUser\Mapper\User
/**
* {@inheritdoc}
*/
public
function
insert
(
$entity
,
$tableName
=
null
,
HydratorInterface
$hydrator
=
null
)
public
function
insert
(
UserEntityInterface
$entity
)
{
return
$this
->
persist
(
$entity
);
}
...
...
@@ -58,12 +74,16 @@ class UserMapper extends \ZfcUser\Mapper\User
/**
* {@inheritdoc}
*/
public
function
update
(
$entity
,
$where
=
null
,
$tableName
=
null
,
HydratorInterface
$hydrator
=
null
)
public
function
update
(
UserEntityInterface
$entity
)
{
return
$this
->
persist
(
$entity
);
}
protected
function
persist
(
$entity
)
/**
* @param UserEntityInterface $entity
* @return mixed
*/
protected
function
persist
(
UserEntityInterface
$entity
)
{
$this
->
em
->
persist
(
$entity
);
$this
->
em
->
flush
();
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment