Select Git revision
ChainServiceFactory.php
Bertrand Gauthier authored
Améliorations importantes : notamment collecte des rôles disponibles et de ceux de l'identité authentifiée.
Code owners
Assign users and groups as approvers for specific file changes. Learn more.
ChainServiceFactory.php 1.20 KiB
<?php
namespace UnicaenAuth\Authentication\Storage;
use Zend\ServiceManager\FactoryInterface;
use Zend\ServiceManager\ServiceLocatorInterface;
/**
* Description of ChainAuthenticationStorageServiceFactory
*
* @author Bertrand GAUTHIER <bertrand.gauthier at unicaen.fr>
*/
class ChainServiceFactory implements FactoryInterface
{
/**
* Create service
*
* @param ServiceLocatorInterface $serviceLocator
* @return mixed
*/
public function createService(ServiceLocatorInterface $serviceLocator)
{
$storages = array(
200 => 'UnicaenAuth\Authentication\Storage\Ldap',
100 => 'UnicaenAuth\Authentication\Storage\Db',
);
$chain = new Chain();
$chain->setServiceLocator($serviceLocator);
foreach ($storages as $priority => $name) {
$storage = $serviceLocator->get($name);
$chain->getEventManager()->attach('read', array($storage, 'read'), $priority);
$chain->getEventManager()->attach('write', array($storage, 'write'), $priority);
$chain->getEventManager()->attach('clear', array($storage, 'clear'), $priority);
}
return $chain;
}
}