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

Corrections pour passer à ZF3.

parent e0827096
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -90,7 +90,7 @@ class Module implements AutoloaderProviderInterface, ConfigProviderInterface, Se
     */
    private function reconfigureRoutesForAuth(ServiceLocatorInterface $sl)
    {
        /* @var $router \Zend\Mvc\Router\Http\TreeRouteStack */
        /* @var $router \Zend\Router\Http\TreeRouteStack */
        $router = $sl->get('router');

        // si l'auth CAS est activée, modif de la route de connexion pour zapper le formulaire d'auth maison.
+1 −1
Original line number Diff line number Diff line
@@ -5,7 +5,7 @@ namespace UnicaenAuth\Assertion;
use BjyAuthorize\Service\Authorize;
use UnicaenAuth\Service\Traits\UserContextServiceAwareTrait;
use Zend\Mvc\Application;
use Zend\Mvc\Controller\Plugin\FlashMessenger;
use Zend\Mvc\Plugin\FlashMessenger\FlashMessenger;
use Zend\Mvc\MvcEvent;
use Zend\Permissions\Acl\Acl;
use Zend\Permissions\Acl\Assertion\AssertionInterface;
+14 −19
Original line number Diff line number Diff line
@@ -2,6 +2,7 @@

namespace UnicaenAuth\Authentication\Adapter;

use Interop\Container\ContainerInterface;
use UnicaenApp\Exception\LogicException;
use Zend\EventManager\EventManager;
use Zend\EventManager\EventManagerAwareInterface;
@@ -15,28 +16,22 @@ use Zend\ServiceManager\ServiceLocatorInterface;
 */
class AbstractFactory implements AbstractFactoryInterface
{
    /**
     * Determine if we can create a service with name
     *
     * @param ServiceLocatorInterface $serviceLocator
     * @param $name
     * @param $requestedName
     * @return bool
     */
    public function canCreateServiceWithName(ServiceLocatorInterface $serviceLocator, $name, $requestedName)
    {
        return strpos($requestedName, __NAMESPACE__) === 0 && class_exists($requestedName);
        return $this->canCreate($serviceLocator, $requestedName);
    }

    /**
     * Create service with name
     *
     * @param ServiceLocatorInterface $serviceLocator
     * @param $name
     * @param $requestedName
     * @return \ZfcUser\Authentication\Adapter\AbstractAdapter
     */
    public function createServiceWithName(ServiceLocatorInterface $serviceLocator, $name, $requestedName)
    {
        return $this->__invoke($serviceLocator, $requestedName);
    }

    public function canCreate(ContainerInterface $container, $requestedName)
    {
        return strpos($requestedName, __NAMESPACE__) === 0 && class_exists($requestedName);
    }

    public function __invoke(ContainerInterface $container, $requestedName, array $options = null)
    {
        switch ($requestedName) {
            case __NAMESPACE__ . '\Ldap':
@@ -61,9 +56,9 @@ class AbstractFactory implements AbstractFactoryInterface

        if ($adapter instanceof EventManagerAwareInterface) {
            /** @var EventManager $eventManager */
            $eventManager = $serviceLocator->get('event_manager');
            $eventManager = $container->get('event_manager');
            $adapter->setEventManager($eventManager);
            $userService = $serviceLocator->get('unicaen-auth_user_service'); /* @var $userService \UnicaenAuth\Service\User */
            $userService = $container->get('unicaen-auth_user_service'); /* @var $userService \UnicaenAuth\Service\User */
            $eventManager->attach('userAuthenticated', [$userService, 'userAuthenticated'], 100);
        }

+1 −1
Original line number Diff line number Diff line
@@ -12,7 +12,7 @@ use Zend\Authentication\Result as AuthenticationResult;
use Zend\EventManager\EventManager;
use Zend\EventManager\EventManagerAwareInterface;
use Zend\EventManager\EventManagerInterface;
use Zend\Mvc\Router\Http\TreeRouteStack;
use Zend\Router\Http\TreeRouteStack;
use Zend\ServiceManager\ServiceLocatorAwareTrait;
use ZfcUser\Authentication\Adapter\AbstractAdapter;
use ZfcUser\Authentication\Adapter\AdapterChainEvent as AuthEvent;
+9 −9
Original line number Diff line number Diff line
@@ -2,9 +2,10 @@

namespace UnicaenAuth\Authentication;

use Interop\Container\ContainerInterface;
use Zend\Authentication\AuthenticationService;
use Zend\ServiceManager\FactoryInterface;
use Zend\ServiceManager\ServiceLocatorInterface;
use Zend\Authentication\AuthenticationService;

/**
 * Description of AuthenticationServiceFactory
@@ -13,17 +14,16 @@ use Zend\Authentication\AuthenticationService;
 */
class AuthenticationServiceFactory implements FactoryInterface
{
    /**
     * Create service
     *
     * @param ServiceLocatorInterface $serviceLocator
     * @return AuthenticationService
     */
    public function createService(ServiceLocatorInterface $serviceLocator)
    {
        return $this->__invoke($serviceLocator, '?');
    }

    public function __invoke(ContainerInterface $container, $requestedName, array $options = null)
    {
        return new AuthenticationService(
            $serviceLocator->get('UnicaenAuth\Authentication\Storage\Chain'),
            $serviceLocator->get('ZfcUser\Authentication\Adapter\AdapterChain')
            $container->get('UnicaenAuth\Authentication\Storage\Chain'),
            $container->get('ZfcUser\Authentication\Adapter\AdapterChain')
        );
    }
}
 No newline at end of file
Loading