Commit 5c57ded8 authored by Bertrand Gauthier's avatar Bertrand Gauthier
Browse files

Corrections pour passer à ZF3.

parent e0827096
Pipeline #3939 passed with stage
in 19 seconds
......@@ -8,7 +8,7 @@ use InvalidArgumentException;
use UnicaenApp\Exception\LogicException;
use UnicaenApp\Exception\RuntimeException;
use UnicaenAuth\Entity\Shibboleth\ShibUser;
use Zend\Mvc\Router\Http\TreeRouteStack;
use Zend\Router\Http\TreeRouteStack;
use Zend\Session\Container;
/**
......
......@@ -2,12 +2,11 @@
namespace UnicaenAuth\Service;
use Interop\Container\ContainerInterface;
use UnicaenAuth\Entity\Ldap\People;
use Zend\ServiceManager\InitializerInterface;
use Zend\ServiceManager\ServiceLocatorInterface;
use UnicaenAuth\Service\DbUserAwareInterface;
use UnicaenAuth\Service\LdapUserAwareInterface;
use ZfcUser\Entity\UserInterface;
use UnicaenAuth\Entity\Ldap\People;
/**
* Initialisateur chargé d'injecter l'utilisateur courant dans les services en ayant besoin.
......@@ -27,13 +26,12 @@ class UserAwareInitializer implements InitializerInterface
return $instance instanceof DbUserAwareInterface || $instance instanceof LdapUserAwareInterface;
}
/**
* Initialize
*
* @param mixed $instance
* @param ServiceLocatorInterface $serviceLocator
*/
public function initialize($instance, ServiceLocatorInterface $serviceLocator)
{
$this->__invoke($serviceLocator, $instance);
}
public function __invoke(ContainerInterface $container, $instance)
{
// test d'éligibilité à faire au plus tôt pour éviter l'erreur
// 'Circular dependency for LazyServiceLoader was found for instance Zend\Authentication\AuthenticationService'
......@@ -41,7 +39,7 @@ class UserAwareInitializer implements InitializerInterface
return;
}
$authenticationService = $serviceLocator->get('Zend\Authentication\AuthenticationService');
$authenticationService = $container->get('Zend\Authentication\AuthenticationService');
if (!$authenticationService->hasIdentity()) {
return;
}
......
......@@ -3,25 +3,25 @@
namespace UnicaenAuth\Service;
use Doctrine\ORM\EntityManagerInterface;
use Interop\Container\ContainerInterface;
use UnicaenAuth\Options\ModuleOptions;
use Zend\ServiceManager\FactoryInterface;
use Zend\ServiceManager\ServiceLocatorInterface;
class UserMapperFactory implements FactoryInterface
{
/**
* Create service
*
* @param ServiceLocatorInterface $serviceLocator
* @return UserMapper
*/
public function createService(ServiceLocatorInterface $serviceLocator)
{
return $this->__invoke($serviceLocator, '?');
}
public function __invoke(ContainerInterface $container, $requestedName, array $options = null)
{
/** @var EntityManagerInterface $em */
$em = $serviceLocator->get('zfcuser_doctrine_em');
$em = $container->get('zfcuser_doctrine_em');
/** @var ModuleOptions $options */
$options = $serviceLocator->get('zfcuser_module_options');
$options = $container->get('zfcuser_module_options');
return new UserMapper($em, $options);
}
......
......@@ -2,6 +2,7 @@
namespace UnicaenAuth\View\Helper;
use Interop\Container\ContainerInterface;
use Zend\ServiceManager\FactoryInterface;
use Zend\ServiceManager\ServiceLocatorInterface;
......@@ -12,15 +13,14 @@ use Zend\ServiceManager\ServiceLocatorInterface;
*/
class UserConnectionFactory implements FactoryInterface
{
/**
* Create service
*
* @param ServiceLocatorInterface $helperPluginManager
* @return UserConnection
*/
public function createService(ServiceLocatorInterface $helperPluginManager)
{
$authUserContext = $helperPluginManager->getServiceLocator()->get('authUserContext');
return $this->__invoke($helperPluginManager, '?');
}
public function __invoke(ContainerInterface $container, $requestedName, array $options = null)
{
$authUserContext = $container->get('authUserContext');
return new UserConnection($authUserContext);
}
......
......@@ -2,6 +2,7 @@
namespace UnicaenAuth\View\Helper;
use Interop\Container\ContainerInterface;
use Zend\ServiceManager\FactoryInterface;
use Zend\ServiceManager\ServiceLocatorInterface;
......@@ -12,15 +13,14 @@ use Zend\ServiceManager\ServiceLocatorInterface;
*/
class UserCurrentFactory implements FactoryInterface
{
/**
* Create service
*
* @param ServiceLocatorInterface $helperPluginManager
* @return UserCurrent
*/
public function createService(ServiceLocatorInterface $helperPluginManager)
{
$authUserContext = $helperPluginManager->getServiceLocator()->get('authUserContext');
return $this->__invoke($helperPluginManager, '?');
}
public function __invoke(ContainerInterface $container, $requestedName, array $options = null)
{
$authUserContext = $container->get('authUserContext');
return new UserCurrent($authUserContext);
}
......
......@@ -2,6 +2,7 @@
namespace UnicaenAuth\View\Helper;
use Interop\Container\ContainerInterface;
use Zend\ServiceManager\FactoryInterface;
use Zend\ServiceManager\ServiceLocatorInterface;
......@@ -12,15 +13,14 @@ use Zend\ServiceManager\ServiceLocatorInterface;
*/
class UserInfoFactory implements FactoryInterface
{
/**
* Create service
*
* @param ServiceLocatorInterface $helperPluginManager
* @return UserInfo
*/
public function createService(ServiceLocatorInterface $helperPluginManager)
{
$serviceLocator = $helperPluginManager->getServiceLocator();
return $this->__invoke($helperPluginManager, '?');
}
public function __invoke(ContainerInterface $container, $requestedName, array $options = null)
{
$serviceLocator = $container;
$authUserContext = $serviceLocator->get('authUserContext');
$mapper = $serviceLocator->get('ldap_structure_mapper');
......
......@@ -2,6 +2,7 @@
namespace UnicaenAuth\View\Helper;
use Interop\Container\ContainerInterface;
use Zend\ServiceManager\FactoryInterface;
use Zend\ServiceManager\ServiceLocatorInterface;
......@@ -12,15 +13,14 @@ use Zend\ServiceManager\ServiceLocatorInterface;
*/
class UserProfileFactory implements FactoryInterface
{
/**
* Create service
*
* @param ServiceLocatorInterface $helperPluginManager
* @return UserProfile
*/
public function createService(ServiceLocatorInterface $helperPluginManager)
{
$serviceLocator = $helperPluginManager->getServiceLocator();
return $this->__invoke($helperPluginManager, '?');
}
public function __invoke(ContainerInterface $container, $requestedName, array $options = null)
{
$serviceLocator = $container;
$authUserContext = $serviceLocator->get('authUserContext');
return new UserProfile($authUserContext);
......
......@@ -2,6 +2,7 @@
namespace UnicaenAuth\View\Helper;
use Interop\Container\ContainerInterface;
use Zend\ServiceManager\FactoryInterface;
use Zend\ServiceManager\ServiceLocatorInterface;
......@@ -12,15 +13,14 @@ use Zend\ServiceManager\ServiceLocatorInterface;
*/
class UserStatusFactory implements FactoryInterface
{
/**
* Create service
*
* @param ServiceLocatorInterface $helperPluginManager
* @return UserStatus
*/
public function createService(ServiceLocatorInterface $helperPluginManager)
{
$userContext = $helperPluginManager->getServiceLocator()->get('authUserContext');
return $this->__invoke($helperPluginManager, '?');
}
public function __invoke(ContainerInterface $container, $requestedName, array $options = null)
{
$userContext = $container->get('authUserContext');
return new UserStatus($userContext);
}
......
......@@ -56,7 +56,7 @@ class CasTest extends PHPUnit_Framework_TestCase
return $moduleOptions;
}
if ('router' === $serviceName) {
$router = new \Zend\Mvc\Router\Http\TreeRouteStack();
$router = new \Zend\Router\Http\TreeRouteStack();
$router->setBaseUrl('/appli')->setRequestUri(new \Zend\Uri\Http('/request'));
return $router;
}
......
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