BasicServiceFactory.php 1 KB
Newer Older
1
2
3
4
<?php

namespace UnicaenAuth\Provider\Identity;

5
use Interop\Container\ContainerInterface;
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
use Zend\ServiceManager\FactoryInterface;
use Zend\ServiceManager\ServiceLocatorInterface;

/**
 * Basic identity provider factory.
 *
 * @author Bertrand GAUTHIER <bertrand.gauthier@unicaen.fr>
 */
class BasicServiceFactory implements FactoryInterface
{
    /**
     * {@inheritDoc}
     */
    public function createService(ServiceLocatorInterface $serviceLocator)
    {
21
22
23
24
25
26
27
        return $this->__invoke($serviceLocator, '?');
    }

    public function __invoke(ContainerInterface $container, $requestedName, array $options = null)
    {
        $user              = $container->get('zfcuser_user_service');
        $config            = $container->get('BjyAuthorize\Config');
28
29
30
31
32
33
34
35
        $identityProvider  = new Basic($user->getAuthService());

        $identityProvider->setDefaultRole($config['default_role']);
        $identityProvider->setAuthenticatedRole($config['authenticated_role']);

        return $identityProvider;
    }
}