diff --git a/src/UnicaenAuth/Assertion/AbstractAssertion.php b/src/UnicaenAuth/Assertion/AbstractAssertion.php index 920bfcfb386a670da7dc708b4d354e3ee7895ec1..5fa454f64bdd9f3082397ae60e2df1356ee8055b 100644 --- a/src/UnicaenAuth/Assertion/AbstractAssertion.php +++ b/src/UnicaenAuth/Assertion/AbstractAssertion.php @@ -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; /** diff --git a/src/UnicaenAuth/Authentication/Adapter/Cas.php b/src/UnicaenAuth/Authentication/Adapter/Cas.php index 562446f4a4c32f5030cc144c24d18f1a9e7f9f05..c26756803bc9fe5c0c525beab672ea21355c49f5 100644 --- a/src/UnicaenAuth/Authentication/Adapter/Cas.php +++ b/src/UnicaenAuth/Authentication/Adapter/Cas.php @@ -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 * diff --git a/src/UnicaenAuth/Authentication/Adapter/Db.php b/src/UnicaenAuth/Authentication/Adapter/Db.php index c216906cad54541e8b4308cb81a3bf33939fe859..4b773a696fff7ca90b31c464058584db2056fc7b 100644 --- a/src/UnicaenAuth/Authentication/Adapter/Db.php +++ b/src/UnicaenAuth/Authentication/Adapter/Db.php @@ -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 diff --git a/src/UnicaenAuth/Authentication/Adapter/Ldap.php b/src/UnicaenAuth/Authentication/Adapter/Ldap.php index b910a79059a6e22176afe19df36ca33c05c729c9..162c4f4385ea56c9a9f86e6582cc9966d74755fa 100644 --- a/src/UnicaenAuth/Authentication/Adapter/Ldap.php +++ b/src/UnicaenAuth/Authentication/Adapter/Ldap.php @@ -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 * diff --git a/src/UnicaenAuth/Authentication/Storage/Db.php b/src/UnicaenAuth/Authentication/Storage/Db.php index 1169c56105f710b72c1c2b5d282c8878944dc42e..cc12bf179e276d604c6995977d95d682f1bb724c 100644 --- a/src/UnicaenAuth/Authentication/Storage/Db.php +++ b/src/UnicaenAuth/Authentication/Storage/Db.php @@ -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 diff --git a/src/UnicaenAuth/Authentication/Storage/Ldap.php b/src/UnicaenAuth/Authentication/Storage/Ldap.php index c3140f7fa417d86f47b473296e2a5432bfd5295c..aaa338f07c422515c372db8e9ed399b5bc2c79d2 100644 --- a/src/UnicaenAuth/Authentication/Storage/Ldap.php +++ b/src/UnicaenAuth/Authentication/Storage/Ldap.php @@ -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; } diff --git a/src/UnicaenAuth/Authentication/Storage/Shib.php b/src/UnicaenAuth/Authentication/Storage/Shib.php index 8d8a81c9178bf4d255581983de3db12fd6adb290..3a2b9f40722ceb53e7026fc660f795cb92d71be0 100644 --- a/src/UnicaenAuth/Authentication/Storage/Shib.php +++ b/src/UnicaenAuth/Authentication/Storage/Shib.php @@ -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; diff --git a/src/UnicaenAuth/Form/Droits/RoleForm.php b/src/UnicaenAuth/Form/Droits/RoleForm.php index ce78cf7eda87ccbb82ae09920ef32388bd8213cf..6f159e71df6251ca68185d353c1047d6bfa84c1e 100644 --- a/src/UnicaenAuth/Form/Droits/RoleForm.php +++ b/src/UnicaenAuth/Form/Droits/RoleForm.php @@ -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; diff --git a/src/UnicaenAuth/Provider/Identity/Chain.php b/src/UnicaenAuth/Provider/Identity/Chain.php index 6d042707e2f344c70be8bd9e3a4c61f5177d751c..93a71e7021b3dd7c38d7689e46846df88ed6e4ba 100644 --- a/src/UnicaenAuth/Provider/Identity/Chain.php +++ b/src/UnicaenAuth/Provider/Identity/Chain.php @@ -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; /** diff --git a/src/UnicaenAuth/Service/AbstractService.php b/src/UnicaenAuth/Service/AbstractService.php index 6ed1d710e51eb6887be836c9a49142a244a7216e..f2def2ba169934e2385bd5cd1ef2050805d47b69 100644 --- a/src/UnicaenAuth/Service/AbstractService.php +++ b/src/UnicaenAuth/Service/AbstractService.php @@ -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 diff --git a/src/UnicaenAuth/Service/User.php b/src/UnicaenAuth/Service/User.php index 1d72db1f6794eb544d817870fe0ffa4b30e6e067..bb7f377cdbce938a03c4caa75fcb7e5f029fa987 100644 --- a/src/UnicaenAuth/Service/User.php +++ b/src/UnicaenAuth/Service/User.php @@ -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; diff --git a/tests/UnicaenAuthTest/Authentication/Adapter/LdapTest.php b/tests/UnicaenAuthTest/Authentication/Adapter/LdapTest.php index 7186f0d4c36b62af7c89e8165b092824a39819c2..38396caebb979dd6805b391adb1c959dd3a0a1de 100644 --- a/tests/UnicaenAuthTest/Authentication/Adapter/LdapTest.php +++ b/tests/UnicaenAuthTest/Authentication/Adapter/LdapTest.php @@ -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()); } diff --git a/tests/UnicaenAuthTest/Authentication/Storage/DbTest.php b/tests/UnicaenAuthTest/Authentication/Storage/DbTest.php index 34503c407643b7bb75c376d81ea002fe80a23996..88aaa180598ad33a3bdd5b4ade7d3dde614a854e 100644 --- a/tests/UnicaenAuthTest/Authentication/Storage/DbTest.php +++ b/tests/UnicaenAuthTest/Authentication/Storage/DbTest.php @@ -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); } diff --git a/tests/UnicaenAuthTest/Authentication/Storage/LdapTest.php b/tests/UnicaenAuthTest/Authentication/Storage/LdapTest.php index 00865465e21ed0d8f4746d6f22a14e88a648a926..eb57ca6b5ae4d330a37f9ff3aa1eb82e3b0c52ec 100644 --- a/tests/UnicaenAuthTest/Authentication/Storage/LdapTest.php +++ b/tests/UnicaenAuthTest/Authentication/Storage/LdapTest.php @@ -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); }