Commit e651370e authored by Bertrand Gauthier's avatar Bertrand Gauthier
Browse files

Utilisation du nouveau service d'accès aux individus LDAP : mapper Ldap.

parent 56355cbe
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
namespace UnicaenAuth\Authentication\Storage; namespace UnicaenAuth\Authentication\Storage;
use UnicaenApp\Entity\Ldap\People; use UnicaenApp\Entity\Ldap\People;
use UnicaenApp\Service\Ldap\People as LdapPeopleService; use UnicaenApp\Mapper\Ldap\People as LdapPeopleMapper;
use UnicaenAuth\Options\ModuleOptions; use UnicaenAuth\Options\ModuleOptions;
use Zend\Authentication\Exception\InvalidArgumentException; use Zend\Authentication\Exception\InvalidArgumentException;
use Zend\Authentication\Storage; use Zend\Authentication\Storage;
...@@ -24,7 +24,7 @@ class Ldap implements Storage\StorageInterface, ServiceManagerAwareInterface ...@@ -24,7 +24,7 @@ class Ldap implements Storage\StorageInterface, ServiceManagerAwareInterface
protected $storage; protected $storage;
/** /**
* @var LdapPeopleService * @var LdapPeopleMapper
*/ */
protected $mapper; protected $mapper;
...@@ -94,6 +94,7 @@ class Ldap implements Storage\StorageInterface, ServiceManagerAwareInterface ...@@ -94,6 +94,7 @@ class Ldap implements Storage\StorageInterface, ServiceManagerAwareInterface
{ {
$this->resolvedIdentity = null; $this->resolvedIdentity = null;
$this->getStorage()->write($contents); $this->getStorage()->write($contents);
return $this;
} }
/** /**
...@@ -106,6 +107,7 @@ class Ldap implements Storage\StorageInterface, ServiceManagerAwareInterface ...@@ -106,6 +107,7 @@ class Ldap implements Storage\StorageInterface, ServiceManagerAwareInterface
{ {
$this->resolvedIdentity = null; $this->resolvedIdentity = null;
$this->getStorage()->clear(); $this->getStorage()->clear();
return $this;
} }
/** /**
...@@ -137,12 +139,12 @@ class Ldap implements Storage\StorageInterface, ServiceManagerAwareInterface ...@@ -137,12 +139,12 @@ class Ldap implements Storage\StorageInterface, ServiceManagerAwareInterface
/** /**
* getMapper * getMapper
* *
* @return LdapPeopleService * @return LdapPeopleMapper
*/ */
public function getMapper() public function getMapper()
{ {
if (null === $this->mapper) { if (null === $this->mapper) {
$this->mapper = $this->getServiceManager()->get('ldap_people_service')->getMapper(); $this->mapper = $this->getServiceManager()->get('ldap_people_mapper');
} }
return $this->mapper; return $this->mapper;
} }
...@@ -150,10 +152,10 @@ class Ldap implements Storage\StorageInterface, ServiceManagerAwareInterface ...@@ -150,10 +152,10 @@ class Ldap implements Storage\StorageInterface, ServiceManagerAwareInterface
/** /**
* setMapper * setMapper
* *
* @param LdapPeopleService $mapper * @param LdapPeopleMapper $mapper
* @return Ldap * @return Ldap
*/ */
public function setMapper(LdapPeopleService $mapper) public function setMapper(LdapPeopleMapper $mapper)
{ {
$this->mapper = $mapper; $this->mapper = $mapper;
return $this; return $this;
...@@ -178,6 +180,7 @@ class Ldap implements Storage\StorageInterface, ServiceManagerAwareInterface ...@@ -178,6 +180,7 @@ class Ldap implements Storage\StorageInterface, ServiceManagerAwareInterface
public function setServiceManager(ServiceManager $serviceManager) public function setServiceManager(ServiceManager $serviceManager)
{ {
$this->serviceManager = $serviceManager; $this->serviceManager = $serviceManager;
return $this;
} }
/** /**
...@@ -186,6 +189,7 @@ class Ldap implements Storage\StorageInterface, ServiceManagerAwareInterface ...@@ -186,6 +189,7 @@ class Ldap implements Storage\StorageInterface, ServiceManagerAwareInterface
public function setOptions(ModuleOptions $options) public function setOptions(ModuleOptions $options)
{ {
$this->options = $options; $this->options = $options;
return $this;
} }
/** /**
......
...@@ -30,10 +30,8 @@ class LdapTest extends PHPUnit_Framework_TestCase ...@@ -30,10 +30,8 @@ class LdapTest extends PHPUnit_Framework_TestCase
$this->mapper = $mapper = $this->getMock('UnicaenApp\Service\Ldap\People', array('findOneByUsername')); $this->mapper = $mapper = $this->getMock('UnicaenApp\Service\Ldap\People', array('findOneByUsername'));
$this->serviceManager = new ServiceManager(); $this->serviceManager = new ServiceManager();
$this->serviceManager->setFactory('ldap_people_service', function() use ($mapper) { $this->serviceManager->setFactory('ldap_people_mapper', function() use ($mapper) {
$service = new \UnicaenApp\Service\Ldap\People(); return $mapper;
$service->setMapper($mapper);
return $service;
}); });
$this->serviceManager->setFactory('unicaen-auth_module_options', function() use ($options) { $this->serviceManager->setFactory('unicaen-auth_module_options', function() use ($options) {
return $options; return $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