Commit 0bdb8970 authored by Bertrand Gauthier's avatar Bertrand Gauthier
Browse files

Petite modification de la ChainServiceFactory : extraction de propriété pour...

Petite modification de la ChainServiceFactory : extraction de propriété pour permettre la surcharge.
parent a4cd96fe
<?php
namespace UnicaenAuth\Authentication\Storage;
use Zend\ServiceManager\FactoryInterface;
......@@ -11,6 +12,11 @@ use Zend\ServiceManager\ServiceLocatorInterface;
*/
class ChainServiceFactory implements FactoryInterface
{
protected $storages = [
200 => 'UnicaenAuth\Authentication\Storage\Ldap',
100 => 'UnicaenAuth\Authentication\Storage\Db',
];
/**
* Create service
*
......@@ -19,14 +25,9 @@ class ChainServiceFactory implements FactoryInterface
*/
public function createService(ServiceLocatorInterface $serviceLocator)
{
$storages = [
200 => 'UnicaenAuth\Authentication\Storage\Ldap',
100 => 'UnicaenAuth\Authentication\Storage\Db',
];
$chain = new Chain();
foreach ($storages as $priority => $name) {
foreach ($this->storages as $priority => $name) {
$storage = $serviceLocator->get($name);
$chain->getEventManager()->attach('read', [$storage, 'read'], $priority);
$chain->getEventManager()->attach('write', [$storage, 'write'], $priority);
......
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