Completed
Push — develop ( b8f7b1...cea6ad )
by
unknown
07:05
created

AclFactory::__invoke()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 14
Code Lines 8

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 14
rs 9.4285
c 0
b 0
f 0
cc 2
eloc 8
nc 2
nop 3
1
<?php
2
3
namespace Acl\Factory\Service;
4
5
use Acl\Config;
6
use Interop\Container\ContainerInterface;
7
use Zend\ServiceManager\FactoryInterface;
8
use Zend\ServiceManager\ServiceLocatorInterface;
9
use Zend\Permissions\Acl\Acl;
10
//use Acl\Service\Acl;
11
12
/**
13
 * authentication adapter factory
14
 */
15
class AclFactory implements FactoryInterface
16
{
17
    /**
18
     * Create an object
19
     *
20
     * @param  ContainerInterface $container
21
     * @param  string             $requestedName
22
     * @param  null|array         $options
23
     *
24
     * @return object
25
     * @throws ServiceNotFoundException if unable to resolve the service.
26
     * @throws ServiceNotCreatedException if an exception is raised when
27
     *     creating a service.
28
     * @throws ContainerException if any other error occurs
29
     */
30
    public function __invoke(ContainerInterface $container, $requestedName, array $options = null)
31
    {
32
        $assertions  = $container->get('Acl\AssertionManager');
33
        $configArray = $container->get('Config');
34
35
        if (!isset($configArray['acl'])) {
36
            throw new \OutOfRangeException('Missing index "acl" in config.');
37
        }
38
39
        $config = new Config($configArray['acl'], $assertions);
40
        $acl = $config->configureAcl(new Acl());
41
42
        return $acl;
43
    }
44
45
46
    /**
47
     * Creates an instance of \Auth\Adapter\ExternalApplication
48
     *
49
     * - injects the UserRepository fetched from the service manager.
50
     *
51
     * @param ServiceLocatorInterface $serviceLocator
52
     * @return \Auth\Adapter\ExternalApplication
53
     * @see \Zend\ServiceManager\FactoryInterface::createService()
54
     */
55
    public function createService(ServiceLocatorInterface $serviceLocator)
56
    {
57
        return $this($serviceLocator, Acl::class);
58
    }
59
}
60