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

Passage à ZF 2.x ; modifications minimales pour le supporter.

parent 9dd896a0
Pipeline #3783 passed with stage
in 17 seconds
......@@ -11,7 +11,7 @@ use Zend\Permissions\Acl\Acl;
use Zend\Permissions\Acl\Assertion\AssertionInterface;
use Zend\Permissions\Acl\Resource\ResourceInterface;
use Zend\Permissions\Acl\Role\RoleInterface;
use Zend\ServiceManager\ServiceLocatorAwareInterface;
use UnicaenApp\ServiceManager\ServiceLocatorAwareInterface;
use Zend\ServiceManager\ServiceLocatorAwareTrait;
/**
......
......@@ -4,6 +4,7 @@ namespace UnicaenAuth\Authentication\Adapter;
use phpCAS;
use UnicaenApp\Mapper\Ldap\People as LdapPeopleMapper;
use UnicaenApp\ServiceManager\ServiceLocatorAwareInterface;
use UnicaenAuth\Options\ModuleOptions;
use UnicaenAuth\Service\User;
use Zend\Authentication\Exception\UnexpectedValueException;
......@@ -12,8 +13,7 @@ use Zend\EventManager\EventManager;
use Zend\EventManager\EventManagerAwareInterface;
use Zend\EventManager\EventManagerInterface;
use Zend\Mvc\Router\Http\TreeRouteStack;
use Zend\ServiceManager\ServiceManager;
use Zend\ServiceManager\ServiceManagerAwareInterface;
use Zend\ServiceManager\ServiceLocatorAwareTrait;
use ZfcUser\Authentication\Adapter\AbstractAdapter;
use ZfcUser\Authentication\Adapter\AdapterChainEvent as AuthEvent;
use ZfcUser\Authentication\Adapter\ChainableAdapter;
......@@ -23,12 +23,9 @@ use ZfcUser\Authentication\Adapter\ChainableAdapter;
*
* @author Bertrand GAUTHIER <bertrand.gauthier@unicaen.fr>
*/
class Cas extends AbstractAdapter implements ServiceManagerAwareInterface, EventManagerAwareInterface
class Cas extends AbstractAdapter implements EventManagerAwareInterface, ServiceLocatorAwareInterface
{
/**
* @var ServiceManager
*/
protected $serviceManager;
use ServiceLocatorAwareTrait;
/**
* @var EventManager
......@@ -105,7 +102,7 @@ class Cas extends AbstractAdapter implements ServiceManagerAwareInterface, Event
$ldapPeople = $this->getLdapPeopleMapper()->findOneByUsername($identity);
/* @var $userService User */
$userService = $this->getServiceManager()->get('unicaen-auth_user_service');
$userService = $this->serviceLocator->get('unicaen-auth_user_service');
$userService->userAuthenticated($ldapPeople);
}
......@@ -120,7 +117,7 @@ class Cas extends AbstractAdapter implements ServiceManagerAwareInterface, Event
return; // NB: l'authentification CAS est désactivée ssi le tableau des options est vide
}
$router = $this->getServiceManager()->get('router'); /* @var $router TreeRouteStack */
$router = $this->serviceLocator->get('router'); /* @var $router TreeRouteStack */
$returnUrl = $router->getRequestUri()->setPath($router->getBaseUrl())->toString();
$this->getCasClient()->logoutWithRedirectService($returnUrl);
}
......@@ -191,8 +188,8 @@ class Cas extends AbstractAdapter implements ServiceManagerAwareInterface, Event
{
if (!$this->options instanceof ModuleOptions) {
$options = array_merge(
$this->getServiceManager()->get('zfcuser_module_options')->toArray(),
$this->getServiceManager()->get('unicaen-auth_module_options')->toArray());
$this->serviceLocator->get('zfcuser_module_options')->toArray(),
$this->serviceLocator->get('unicaen-auth_module_options')->toArray());
$this->setOptions(new ModuleOptions($options));
}
return $this->options;
......@@ -206,7 +203,7 @@ class Cas extends AbstractAdapter implements ServiceManagerAwareInterface, Event
public function getLdapPeopleMapper()
{
if (null === $this->ldapPeopleMapper) {
$this->ldapPeopleMapper = $this->getServiceManager()->get('ldap_people_mapper');
$this->ldapPeopleMapper = $this->serviceLocator->get('ldap_people_mapper');
}
return $this->ldapPeopleMapper;
}
......@@ -223,28 +220,6 @@ class Cas extends AbstractAdapter implements ServiceManagerAwareInterface, Event
return $this;
}
/**
* Get service manager
*
* @return ServiceManager
*/
public function getServiceManager()
{
return $this->serviceManager;
}
/**
* Set service manager
*
* @param ServiceManager $serviceManager
* @return self
*/
public function setServiceManager(ServiceManager $serviceManager)
{
$this->serviceManager = $serviceManager;
return $this;
}
/**
* Retrieve EventManager instance
*
......
......@@ -2,10 +2,11 @@
namespace UnicaenAuth\Authentication\Adapter;
use UnicaenApp\ServiceManager\ServiceLocatorAwareInterface;
use UnicaenAuth\Options\ModuleOptions;
use Zend\ServiceManager\Exception\ServiceNotFoundException;
use Zend\ServiceManager\ServiceManager;
use Zend\ServiceManager\ServiceManagerAwareInterface;
use Zend\ServiceManager\ServiceLocatorAwareTrait;
use Zend\ServiceManager\ServiceLocatorInterface;
use ZfcUser\Authentication\Adapter\AdapterChainEvent as AuthEvent;
use ZfcUser\Options\AuthenticationOptionsInterface;
......@@ -17,12 +18,24 @@ use ZfcUser\Options\AuthenticationOptionsInterface;
*
* @author Bertrand GAUTHIER <bertrand.gauthier@unicaen.fr>
*/
class Db extends \ZfcUser\Authentication\Adapter\Db implements ServiceManagerAwareInterface
class Db extends \ZfcUser\Authentication\Adapter\Db implements ServiceLocatorAwareInterface
{
use ServiceLocatorAwareTrait;
/**
* @var ServiceManager
* Set service locator
*
* @param ServiceLocatorInterface $serviceLocator
* @return self
* @deprecated Abandonnez l'injection du service locator, svp
*/
protected $serviceManager;
public function setServiceLocator(ServiceLocatorInterface $serviceLocator)
{
$this->serviceLocator = $serviceLocator;
$this->serviceManager = $serviceLocator;
return $this;
}
/**
* Authentification.
......@@ -66,26 +79,4 @@ class Db extends \ZfcUser\Authentication\Adapter\Db implements ServiceManagerAwa
}
return $this->options;
}
/**
* Get service manager
*
* @return ServiceManager
*/
public function getServiceManager()
{
return $this->serviceManager;
}
/**
* Set service manager
*
* @param ServiceManager $serviceManager
* @return self
*/
public function setServiceManager(ServiceManager $serviceManager)
{
$this->serviceManager = $serviceManager;
return $this;
}
}
\ No newline at end of file
......@@ -4,6 +4,7 @@ namespace UnicaenAuth\Authentication\Adapter;
use UnicaenApp\Exception\RuntimeException;
use UnicaenApp\Mapper\Ldap\People as LdapPeopleMapper;
use UnicaenApp\ServiceManager\ServiceLocatorAwareInterface;
use UnicaenAuth\Options\ModuleOptions;
use UnicaenAuth\Service\User;
use Zend\Authentication\Adapter\Ldap as LdapAuthAdapter;
......@@ -13,8 +14,7 @@ use Zend\EventManager\Event;
use Zend\EventManager\EventManager;
use Zend\EventManager\EventManagerAwareInterface;
use Zend\EventManager\EventManagerInterface;
use Zend\ServiceManager\ServiceManager;
use Zend\ServiceManager\ServiceManagerAwareInterface;
use Zend\ServiceManager\ServiceLocatorAwareTrait;
use ZfcUser\Authentication\Adapter\AbstractAdapter;
use ZfcUser\Authentication\Adapter\AdapterChainEvent as AuthEvent;
use ZfcUser\Authentication\Adapter\ChainableAdapter;
......@@ -24,14 +24,11 @@ use ZfcUser\Authentication\Adapter\ChainableAdapter;
*
* @author Bertrand GAUTHIER <bertrand.gauthier@unicaen.fr>
*/
class Ldap extends AbstractAdapter implements ServiceManagerAwareInterface, EventManagerAwareInterface
class Ldap extends AbstractAdapter implements ServiceLocatorAwareInterface, EventManagerAwareInterface
{
const USURPATION_USERNAMES_SEP = '=';
use ServiceLocatorAwareTrait;
/**
* @var ServiceManager
*/
protected $serviceManager;
const USURPATION_USERNAMES_SEP = '=';
/**
* @var EventManager
......@@ -122,7 +119,7 @@ class Ldap extends AbstractAdapter implements ServiceManagerAwareInterface, Even
->setMessages(['Authentication successful.']);
/* @var $userService User */
$userService = $this->getServiceManager()->get('unicaen-auth_user_service');
$userService = $this->serviceLocator->get('unicaen-auth_user_service');
$userService->userAuthenticated($ldapPeople);
}
......@@ -207,7 +204,7 @@ class Ldap extends AbstractAdapter implements ServiceManagerAwareInterface, Even
public function getLdapPeopleMapper()
{
if (null === $this->ldapPeopleMapper) {
$this->ldapPeopleMapper = $this->getServiceManager()->get('ldap_people_mapper');
$this->ldapPeopleMapper = $this->serviceLocator->get('ldap_people_mapper');
}
return $this->ldapPeopleMapper;
}
......@@ -239,8 +236,8 @@ class Ldap extends AbstractAdapter implements ServiceManagerAwareInterface, Even
{
if (!$this->options instanceof ModuleOptions) {
$options = array_merge(
$this->getServiceManager()->get('zfcuser_module_options')->toArray(),
$this->getServiceManager()->get('unicaen-auth_module_options')->toArray());
$this->serviceLocator->get('zfcuser_module_options')->toArray(),
$this->serviceLocator->get('unicaen-auth_module_options')->toArray());
$this->setOptions(new ModuleOptions($options));
}
return $this->options;
......@@ -251,7 +248,7 @@ class Ldap extends AbstractAdapter implements ServiceManagerAwareInterface, Even
*/
public function getAppModuleOptions()
{
return $this->getServiceManager()->get('unicaen-app_module_options');
return $this->serviceLocator->get('unicaen-app_module_options');
}
/**
......@@ -285,28 +282,6 @@ class Ldap extends AbstractAdapter implements ServiceManagerAwareInterface, Even
return $this;
}
/**
* Get service manager
*
* @return ServiceManager
*/
public function getServiceManager()
{
return $this->serviceManager;
}
/**
* Set service manager
*
* @param ServiceManager $serviceManager
* @return Ldap
*/
public function setServiceManager(ServiceManager $serviceManager)
{
$this->serviceManager = $serviceManager;
return $this;
}
/**
* Retrieve EventManager instance
*
......
......@@ -3,11 +3,11 @@
namespace UnicaenAuth\Authentication\Storage;
use Doctrine\DBAL\DBALException;
use UnicaenApp\ServiceManager\ServiceLocatorAwareInterface;
use Zend\Authentication\Storage\Session;
use Zend\Authentication\Storage\StorageInterface;
use Zend\ServiceManager\Exception\ServiceNotFoundException;
use Zend\ServiceManager\ServiceManager;
use Zend\ServiceManager\ServiceManagerAwareInterface;
use Zend\ServiceManager\ServiceLocatorAwareTrait;
use ZfcUser\Mapper\UserInterface as UserMapper;
/**
......@@ -15,8 +15,10 @@ use ZfcUser\Mapper\UserInterface as UserMapper;
*
* @author Bertrand GAUTHIER <bertrand.gauthier at unicaen.fr>
*/
class Db implements ChainableStorage, ServiceManagerAwareInterface
class Db implements ChainableStorage, ServiceLocatorAwareInterface
{
use ServiceLocatorAwareTrait;
/**
* @var StorageInterface
*/
......@@ -32,11 +34,6 @@ class Db implements ChainableStorage, ServiceManagerAwareInterface
*/
protected $resolvedIdentity;
/**
* @var ServiceManager
*/
protected $serviceManager;
/**
* Returns the contents of storage
*
......@@ -177,7 +174,7 @@ class Db implements ChainableStorage, ServiceManagerAwareInterface
public function getMapper()
{
if (null === $this->mapper) {
$this->mapper = $this->getServiceManager()->get('zfcuser_user_mapper');
$this->mapper = $this->serviceLocator->get('zfcuser_user_mapper');
}
return $this->mapper;
}
......@@ -193,26 +190,4 @@ class Db implements ChainableStorage, ServiceManagerAwareInterface
$this->mapper = $mapper;
return $this;
}
/**
* Retrieve service manager instance
*
* @return ServiceManager
*/
public function getServiceManager()
{
return $this->serviceManager;
}
/**
* Set service manager instance
*
* @param ServiceManager $serviceManager
* @return self
*/
public function setServiceManager(ServiceManager $serviceManager)
{
$this->serviceManager = $serviceManager;
return $this;
}
}
\ No newline at end of file
......@@ -2,22 +2,25 @@
namespace UnicaenAuth\Authentication\Storage;
use UnicaenAuth\Entity\Ldap\People;
use UnicaenApp\Mapper\Ldap\People as LdapPeopleMapper;
use UnicaenApp\ServiceManager\ServiceLocatorAwareInterface;
use UnicaenAuth\Entity\Ldap\People;
use UnicaenAuth\Options\ModuleOptions;
use Zend\Authentication\Exception\InvalidArgumentException;
use Zend\Authentication\Storage\Session;
use Zend\Authentication\Storage\StorageInterface;
use Zend\ServiceManager\ServiceLocatorAwareTrait;
use Zend\ServiceManager\ServiceManager;
use Zend\ServiceManager\ServiceManagerAwareInterface;
use Zend\Authentication\Storage\Session;
/**
* Ldap authentication storage.
*
* @author Bertrand GAUTHIER <bertrand.gauthier at unicaen.fr>
*/
class Ldap implements ChainableStorage, ServiceManagerAwareInterface
class Ldap implements ChainableStorage, ServiceLocatorAwareInterface
{
use ServiceLocatorAwareTrait;
/**
* @var StorageInterface
*/
......@@ -38,11 +41,6 @@ class Ldap implements ChainableStorage, ServiceManagerAwareInterface
*/
protected $resolvedIdentity;
/**
* @var ServiceManager
*/
protected $serviceManager;
/**
* Returns the contents of storage
*
......@@ -154,7 +152,7 @@ class Ldap implements ChainableStorage, ServiceManagerAwareInterface
public function getMapper()
{
if (null === $this->mapper) {
$this->mapper = $this->getServiceManager()->get('ldap_people_mapper');
$this->mapper = $this->serviceLocator->get('ldap_people_mapper');
}
return $this->mapper;
}
......@@ -171,28 +169,6 @@ class Ldap implements ChainableStorage, ServiceManagerAwareInterface
return $this;
}
/**
* Retrieve service manager instance
*
* @return ServiceManager
*/
public function getServiceManager()
{
return $this->serviceManager;
}
/**
* Set service manager instance
*
* @param ServiceManager $locator
* @return self
*/
public function setServiceManager(ServiceManager $serviceManager)
{
$this->serviceManager = $serviceManager;
return $this;
}
/**
* @param ModuleOptions $options
*/
......@@ -208,7 +184,7 @@ class Ldap implements ChainableStorage, ServiceManagerAwareInterface
public function getOptions()
{
if (!$this->options instanceof ModuleOptions) {
$this->setOptions($this->getServiceManager()->get('unicaen-auth_module_options'));
$this->setOptions($this->serviceLocator->get('unicaen-auth_module_options'));
}
return $this->options;
}
......
......@@ -6,7 +6,7 @@ use UnicaenAuth\Entity\Shibboleth\ShibUser;
use UnicaenAuth\Service\ShibService;
use Zend\Authentication\Storage\Session;
use Zend\Authentication\Storage\StorageInterface;
use Zend\ServiceManager\ServiceLocatorAwareInterface;
use UnicaenApp\ServiceManager\ServiceLocatorAwareInterface;
use Zend\ServiceManager\ServiceLocatorAwareTrait;
use Zend\ServiceManager\ServiceManager;
......
......@@ -6,7 +6,7 @@ use UnicaenAuth\Entity\Db\Role;
use UnicaenAuth\Service\Traits\RoleServiceAwareTrait;
use Zend\Form\Form;
use UnicaenApp\Util;
use Zend\ServiceManager\ServiceLocatorAwareInterface;
use UnicaenApp\ServiceManager\ServiceLocatorAwareInterface;
use Zend\ServiceManager\ServiceLocatorAwareTrait;
use Zend\Stdlib\Hydrator\HydratorInterface;
use Zend\InputFilter\InputFilterProviderInterface;
......
......@@ -8,7 +8,7 @@ use Zend\EventManager\EventManagerAwareInterface;
use Zend\EventManager\EventManagerAwareTrait;
use Zend\Permissions\Acl\Role\Registry;
use Zend\Permissions\Acl\Role\RoleInterface;
use Zend\ServiceManager\ServiceLocatorAwareInterface;
use UnicaenApp\ServiceManager\ServiceLocatorAwareInterface;
use Zend\ServiceManager\ServiceLocatorAwareTrait;
/**
......
......@@ -4,7 +4,7 @@ namespace UnicaenAuth\Service;
use UnicaenApp\Service\EntityManagerAwareTrait;
use UnicaenAuth\Options\ModuleOptions;
use Zend\ServiceManager\ServiceLocatorAwareInterface;
use UnicaenApp\ServiceManager\ServiceLocatorAwareInterface;
use Zend\ServiceManager\ServiceLocatorAwareTrait;
abstract class AbstractService implements ServiceLocatorAwareInterface
......
......@@ -20,7 +20,7 @@ use Zend\Form\Element\Submit;
use Zend\Form\Element\Text;
use Zend\Form\Form;
use Zend\InputFilter\Input;
use Zend\ServiceManager\ServiceLocatorAwareInterface;
use UnicaenApp\ServiceManager\ServiceLocatorAwareInterface;
use Zend\ServiceManager\ServiceLocatorAwareTrait;
use Zend\Validator\EmailAddress;
use Zend\Validator\Identical;
......
......@@ -69,7 +69,7 @@ class LdapTest extends PHPUnit_Framework_TestCase
}));
$this->adapter = new Ldap();
$this->adapter->setServiceManager($serviceManager)
$this->adapter->setServiceLocator($serviceManager)
->setEventManager(new EventManager());
}
......
......@@ -34,7 +34,7 @@ class DbTest extends PHPUnit_Framework_TestCase
$this->storage = new Db();
$this->storage->setMapper($this->mapper)
->setServiceManager($this->serviceManager)
->setServiceLocator($this->serviceManager)
->setStorage($this->innerStorage);
}
......
......@@ -36,7 +36,7 @@ class LdapTest extends PHPUnit_Framework_TestCase
$this->storage = new Ldap();
$this->storage->setMapper($this->mapper)
->setServiceManager($this->serviceManager)
->setServiceLocator($this->serviceManager)
->setStorage($this->innerStorage);
}
......
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