Commit 8b2b7202 authored by Bertrand Gauthier's avatar Bertrand Gauthier
Browse files

Merge branch 'zf-2.x' of git.unicaen.fr:lib/unicaen/auth into zf-2.x

parents b7967a21 a6c8e699
Pipeline #3822 passed with stage
in 21 seconds
......@@ -118,6 +118,13 @@ class Module implements AutoloaderProviderInterface, ConfigProviderInterface, Se
public function getServiceConfig()
{
return [
//========== repris du module zf-commons/zfc-user-doctrine-orm abandonné =========
'aliases' => array(
'zfcuser_doctrine_em' => 'Doctrine\ORM\EntityManager',
),
//===========================================
'factories' => [
//========== repris du module zf-commons/zfc-user-doctrine-orm abandonné =========
'zfcuser_module_options' => function ($sm) {
......
......@@ -35,7 +35,7 @@ La commande ci-dessus fonctionne seulement si le binaire composer.phar se trouve
'modules' => array(
'Application',
'ZfcBase', 'DoctrineModule', 'DoctrineORMModule', 'ZfcUser', 'ZfcUserDoctrineORM', 'BjyAuthorize',
'ZfcBase', 'DoctrineModule', 'DoctrineORMModule', 'ZfcUser', 'BjyAuthorize',
'UnicaenApp', 'AssetManager',
'UnicaenAuth',
// ...
......
......@@ -2,11 +2,73 @@
namespace UnicaenAuth\Service;
use Doctrine\ORM\EntityManagerInterface;
use UnicaenAuth\Entity\Db\AbstractUser;
use ZfcUserDoctrineORM\Mapper\User as ZfcUserDoctrineORMUserMapper;
use UnicaenAuth\Options\ModuleOptions;
use Zend\Hydrator\HydratorInterface;
use ZfcUser\Entity\UserInterface;
class UserMapper extends ZfcUserDoctrineORMUserMapper
class UserMapper extends \ZfcUser\Mapper\User
{
//========== repris du module zf-commons/zfc-user-doctrine-orm abandonné =========
/**
* @var \Doctrine\ORM\EntityManagerInterface
*/
protected $em;
/**
* @var ModuleOptions
*/
protected $options;
public function __construct(EntityManagerInterface $em, ModuleOptions $options)
{
$this->em = $em;
$this->options = $options;
}
public function findByEmail($email)
{
$er = $this->em->getRepository($this->options->getUserEntityClass());
return $er->findOneBy(array('email' => $email));
}
public function findByUsername($username)
{
$er = $this->em->getRepository($this->options->getUserEntityClass());
return $er->findOneBy(array('username' => $username));
}
public function findById($id)
{
$er = $this->em->getRepository($this->options->getUserEntityClass());
return $er->find($id);
}
public function insert(UserInterface $entity, $tableName = null, HydratorInterface $hydrator = null)
{
return $this->persist($entity);
}
public function update(UserInterface $entity, $where = null, $tableName = null, HydratorInterface $hydrator = null)
{
return $this->persist($entity);
}
protected function persist($entity)
{
$this->em->persist($entity);
$this->em->flush();
return $entity;
}
//===================
/**
* Recherche un utilisateur par son username (identifiant de connexion).
*
......
......@@ -3,6 +3,7 @@
namespace UnicaenAuth\Service;
use Doctrine\ORM\EntityManagerInterface;
use UnicaenAuth\Options\ModuleOptions;
use Zend\ServiceManager\FactoryInterface;
use Zend\ServiceManager\ServiceLocatorInterface;
......@@ -19,7 +20,7 @@ class UserMapperFactory implements FactoryInterface
/** @var EntityManagerInterface $em */
$em = $serviceLocator->get('zfcuser_doctrine_em');
/** @var \ZfcUserDoctrineORM\Options\ModuleOptions $options */
/** @var ModuleOptions $options */
$options = $serviceLocator->get('zfcuser_module_options');
return new UserMapper($em, $options);
......
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