Completed
Push — master ( 843e94...46dd70 )
by Андрей
6s
created

ResolverByClassNameFactory::createService()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 14
Code Lines 7

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 14
rs 9.4285
cc 2
eloc 7
nc 2
nop 1
1
<?php
2
/**
3
 * @link    https://github.com/nnx-framework/entry-name-resolver
4
 * @author  Malofeykin Andrey  <[email protected]>
5
 */
6
namespace Nnx\EntryNameResolver;
7
8
use Nnx\ModuleOptions\ModuleOptionsPluginManagerInterface;
9
use Zend\ServiceManager\AbstractPluginManager;
10
use Zend\ServiceManager\FactoryInterface;
11
use Zend\ServiceManager\MutableCreationOptionsInterface;
12
use Zend\ServiceManager\ServiceLocatorInterface;
13
use Zend\ServiceManager\MutableCreationOptionsTrait;
14
15
/**
16
 * Class ResolverByClassNameFactory
17
 *
18
 * @package Nnx\EntryNameResolver
19
 */
20
class ResolverByClassNameFactory implements FactoryInterface, MutableCreationOptionsInterface
21
{
22
    use MutableCreationOptionsTrait;
23
24
    /**
25
     * @inheritdoc
26
     *
27
     * @param ServiceLocatorInterface $serviceLocator
28
     *
29
     * @return ResolverByModuleContextMap
30
     *
31
     * @throws \Zend\ServiceManager\Exception\ServiceNotFoundException
32
     */
33
    public function createService(ServiceLocatorInterface $serviceLocator)
34
    {
35
        $appServiceLocator = $serviceLocator;
36
        if ($serviceLocator instanceof AbstractPluginManager) {
37
            $appServiceLocator = $serviceLocator->getServiceLocator();
38
        }
39
40
        /** @var ModuleOptionsPluginManagerInterface $moduleOptionsPluginManager */
41
        $moduleOptionsPluginManager = $appServiceLocator->get(ModuleOptionsPluginManagerInterface::class);
42
43
        $resolverByModuleContextMap = new ResolverByClassName($moduleOptionsPluginManager);
44
45
        return $resolverByModuleContextMap;
46
    }
47
}
48