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

Ajout de factories manquantes pour les services.

Tests unitaires correspondants.
parent 6e00cde4
Loading
Loading
Loading
Loading
+0 −1
Original line number Diff line number Diff line
@@ -6,7 +6,6 @@ use Zend\ModuleManager\Feature\AutoloaderProviderInterface;
use Zend\ModuleManager\Feature\ConfigProviderInterface;
use Zend\ModuleManager\Feature\ServiceProviderInterface;
use Zend\ModuleManager\Feature\ViewHelperProviderInterface;
use Zend\View\HelperPluginManager;

/**
 * Point d'entrée du module d'authentification Unicaen.
+5 −23
Original line number Diff line number Diff line
@@ -160,33 +160,15 @@ return array(
        ),
        'invokables' => array(
            'unicaen-auth_user_service'               => 'UnicaenAuth\Service\User',
            'UnicaenAuth\Authentication\Storage\Db'   => 'UnicaenAuth\Authentication\Storage\Db',
            'UnicaenAuth\Authentication\Storage\Ldap' => 'UnicaenAuth\Authentication\Storage\Ldap',
        ),
        'abstract_factories' => array(
            'UnicaenAuth\Authentication\Adapter\AbstractFactory',
        ),
        'factories' => array(
            'unicaen-auth_module_options' => function(Zend\ServiceManager\ServiceLocatorInterface $serviceLocator) {
                $config = $serviceLocator->get('Config');
                return new UnicaenAuth\Options\ModuleOptions(array_merge($config['zfcuser'], $config['unicaen-auth']));
            },
            'UnicaenAuth\Authentication\Storage\Db' => function() {
                return new UnicaenAuth\Authentication\Storage\Db();
            },
            'UnicaenAuth\Authentication\Storage\Ldap' => function() {
                return new UnicaenAuth\Authentication\Storage\Ldap();
            },
            'UnicaenAuth\Authentication\Storage\LdapDb' => function(Zend\ServiceManager\ServiceLocatorInterface $serviceLocator) {
                $storage = new UnicaenAuth\Authentication\Storage\LdapDb();
                $storage->setLdapStorage($serviceLocator->get('UnicaenAuth\Authentication\Storage\Ldap'))
                        ->setDbStorage(  $serviceLocator->get('UnicaenAuth\Authentication\Storage\Db'));
                return $storage;
            },
            'zfcuser_auth_service' => function (Zend\ServiceManager\ServiceLocatorInterface $serviceLocator) {
                return new \Zend\Authentication\AuthenticationService(
                    $serviceLocator->get('UnicaenAuth\Authentication\Storage\Chain'),
                    $serviceLocator->get('ZfcUser\Authentication\Adapter\AdapterChain')
                );
            },
            'unicaen-auth_module_options'              => 'UnicaenAuth\Options\ModuleOptionsFactory',
            'zfcuser_auth_service'                     => 'UnicaenAuth\Authentication\AuthenticationServiceFactory',
            'UnicaenAuth\Authentication\Storage\Chain' => 'UnicaenAuth\Authentication\Storage\ChainServiceFactory',
            'UnicaenAuth\Provider\Identity\Chain'      => 'UnicaenAuth\Provider\Identity\ChainServiceFactory',
            'UnicaenAuth\Provider\Identity\Ldap'       => 'UnicaenAuth\Provider\Identity\LdapServiceFactory',
+1 −1
Original line number Diff line number Diff line
@@ -24,6 +24,6 @@ $settings = array(
return array(
    'unicaen-auth' => $settings,
    'zfcuser'      => array(
        $k='enable_registration' => isset($settings[$k]) ? $settings[$k] : false,
        'enable_registration' => isset($settings['enable_registration']) ? $settings['enable_registration'] : false,
    ),
);
 No newline at end of file
+29 −0
Original line number Diff line number Diff line
<?php

namespace UnicaenAuth\Authentication;

use Zend\ServiceManager\FactoryInterface;
use Zend\ServiceManager\ServiceLocatorInterface;
use Zend\Authentication\AuthenticationService;

/**
 * Description of AuthenticationServiceFactory
 *
 * @author Bertrand GAUTHIER <bertrand.gauthier at unicaen.fr>
 */
class AuthenticationServiceFactory implements FactoryInterface
{
    /**
     * Create service
     *
     * @param ServiceLocatorInterface $serviceLocator
     * @return AuthenticationService
     */
    public function createService(ServiceLocatorInterface $serviceLocator)
    {
        return new AuthenticationService(
            $serviceLocator->get('UnicaenAuth\Authentication\Storage\Chain'),
            $serviceLocator->get('ZfcUser\Authentication\Adapter\AdapterChain')
        );
    }
}
 No newline at end of file
+29 −0
Original line number Diff line number Diff line
<?php

namespace UnicaenAuth\Options;

use Zend\ServiceManager\FactoryInterface;
use Zend\ServiceManager\ServiceLocatorInterface;

/**
 * Description of ModuleOptionsFactory
 *
 * @author Bertrand GAUTHIER <bertrand.gauthier at unicaen.fr>
 */
class ModuleOptionsFactory implements FactoryInterface
{
    /**
     * Create service
     *
     * @param ServiceLocatorInterface $serviceLocator
     * @return mixed
     */
    public function createService(ServiceLocatorInterface $serviceLocator)
    {
        $config       = $serviceLocator->get('Configuration');
        $moduleConfig = isset($config['unicaen-auth']) ? $config['unicaen-auth'] : array();
        $moduleConfig = array_merge($config['zfcuser'], $moduleConfig);
                
        return new ModuleOptions($moduleConfig);
    }
}
 No newline at end of file
Loading