Commit f6d8df4d authored by Bertrand Gauthier's avatar Bertrand Gauthier

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;
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 extends \ZfcUser\Mapper\User
class UserMapper implements 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();
......
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