Commit f6d8df4d authored by Bertrand Gauthier's avatar 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
...@@ -5,9 +5,10 @@ namespace UnicaenAuth\Service; ...@@ -5,9 +5,10 @@ namespace UnicaenAuth\Service;
use Doctrine\ORM\EntityManagerInterface; use Doctrine\ORM\EntityManagerInterface;
use UnicaenAuth\Entity\Db\AbstractUser; use UnicaenAuth\Entity\Db\AbstractUser;
use UnicaenAuth\Options\ModuleOptions; use UnicaenAuth\Options\ModuleOptions;
use Zend\Hydrator\HydratorInterface; use ZfcUser\Entity\UserInterface as UserEntityInterface;
use ZfcUser\Mapper\UserInterface;
class UserMapper extends \ZfcUser\Mapper\User class UserMapper implements UserInterface
{ {
//========== repris du module zf-commons/zfc-user-doctrine-orm abandonné ========= //========== repris du module zf-commons/zfc-user-doctrine-orm abandonné =========
/** /**
...@@ -20,12 +21,21 @@ class UserMapper extends \ZfcUser\Mapper\User ...@@ -20,12 +21,21 @@ class UserMapper extends \ZfcUser\Mapper\User
*/ */
protected $options; protected $options;
/**
* UserMapper constructor.
*
* @param EntityManagerInterface $em
* @param ModuleOptions $options
*/
public function __construct(EntityManagerInterface $em, ModuleOptions $options) public function __construct(EntityManagerInterface $em, ModuleOptions $options)
{ {
$this->em = $em; $this->em = $em;
$this->options = $options; $this->options = $options;
} }
/**
* {@inheritdoc}
*/
public function findByEmail($email) public function findByEmail($email)
{ {
$er = $this->em->getRepository($this->options->getUserEntityClass()); $er = $this->em->getRepository($this->options->getUserEntityClass());
...@@ -33,6 +43,9 @@ class UserMapper extends \ZfcUser\Mapper\User ...@@ -33,6 +43,9 @@ class UserMapper extends \ZfcUser\Mapper\User
return $er->findOneBy(array('email' => $email)); return $er->findOneBy(array('email' => $email));
} }
/**
* {@inheritdoc}
*/
public function findByUsername($username) public function findByUsername($username)
{ {
$er = $this->em->getRepository($this->options->getUserEntityClass()); $er = $this->em->getRepository($this->options->getUserEntityClass());
...@@ -40,6 +53,9 @@ class UserMapper extends \ZfcUser\Mapper\User ...@@ -40,6 +53,9 @@ class UserMapper extends \ZfcUser\Mapper\User
return $er->findOneBy(array('username' => $username)); return $er->findOneBy(array('username' => $username));
} }
/**
* {@inheritdoc}
*/
public function findById($id) public function findById($id)
{ {
$er = $this->em->getRepository($this->options->getUserEntityClass()); $er = $this->em->getRepository($this->options->getUserEntityClass());
...@@ -50,7 +66,7 @@ class UserMapper extends \ZfcUser\Mapper\User ...@@ -50,7 +66,7 @@ class UserMapper extends \ZfcUser\Mapper\User
/** /**
* {@inheritdoc} * {@inheritdoc}
*/ */
public function insert($entity, $tableName = null, HydratorInterface $hydrator = null) public function insert(UserEntityInterface $entity)
{ {
return $this->persist($entity); return $this->persist($entity);
} }
...@@ -58,12 +74,16 @@ class UserMapper extends \ZfcUser\Mapper\User ...@@ -58,12 +74,16 @@ class UserMapper extends \ZfcUser\Mapper\User
/** /**
* {@inheritdoc} * {@inheritdoc}
*/ */
public function update($entity, $where = null, $tableName = null, HydratorInterface $hydrator = null) public function update(UserEntityInterface $entity)
{ {
return $this->persist($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->persist($entity);
$this->em->flush(); $this->em->flush();
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment