Commit 790c5fdd authored by Bertrand Gauthier's avatar Bertrand Gauthier
Browse files

Allègement de la factory BaseProvidersServiceFactory.

parent ae87c01b
Loading
Loading
Loading
Loading
+3 −16
Original line number Diff line number Diff line
@@ -4,27 +4,15 @@ namespace BjyAuthorize\Service;

use BjyAuthorize\Provider\Rule\ProviderInterface;
use Interop\Container\ContainerInterface;
use Zend\ServiceManager\FactoryInterface;
use Zend\ServiceManager\ServiceLocatorInterface;

/**
 * Base factory responsible of instantiating providers
 *
 * @author Marco Pivetta <ocramius@gmail.com>
 */
abstract class BaseProvidersServiceFactory implements FactoryInterface
abstract class BaseProvidersServiceFactory
{
    const PROVIDER_SETTING = 'providers';

    /**
     * {@inheritDoc}
     */
    public function createService(ServiceLocatorInterface $serviceLocator)
    {
        return $this->__invoke($serviceLocator, '?');
    }

    public function __invoke(ContainerInterface $container, $requestedName, array $options = null)
    public function __invoke(ContainerInterface $container)
    {
        $config    = $container->get('BjyAuthorize\Config');
        $providers = array();
@@ -32,8 +20,7 @@ abstract class BaseProvidersServiceFactory implements FactoryInterface
        foreach ($config[static::PROVIDER_SETTING] as $providerName => $providerConfig) {
            if ($container->has($providerName)) {
                $provider = $container->get($providerName);
                if (method_exists($provider, 'setConfig')) {
//                if ($provider instanceof ProviderInterface) {
                if ($provider instanceof ProviderInterface) {
                    $provider->setConfig($providerConfig);
                    $provider->processConfig();
                }