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
Loading
Loading
Loading
Loading
+7 −6
Original line number Diff line number Diff line
<?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);