DbRoleServiceFactory.php 819 Bytes
Newer Older
1
2
3
4
<?php

namespace UnicaenAuth\Provider\Role;

5
use Interop\Container\ContainerInterface;
6
use UnicaenAuth\Service\RoleService;
7
8
9
10
use Zend\ServiceManager\FactoryInterface;
use Zend\ServiceManager\ServiceLocatorInterface;

/**
11
 * Factory responsible of instantiating {@see \UnicaenAuth\Provider\Role\DbRole}
12
 */
13
class DbRoleServiceFactory implements FactoryInterface
14
15
16
17
18
19
{
    /**
     * {@inheritDoc}
     */
    public function createService(ServiceLocatorInterface $serviceLocator)
    {
20
21
22
23
24
25
        return $this->__invoke($serviceLocator, '?');
    }

    public function __invoke(ContainerInterface $container, $requestedName, array $options = null)
    {
        $serviceRole = $container->get('UnicaenAuth\Service\Role');
26
        /* @var $serviceRole RoleService */
27

28
        return new DbRole($serviceRole->getRepo());
29
30
    }
}