Completed
Push — master ( 99ca87...95904e )
by Andrey
23:44
created

ImportEngineFactory::createService()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 17
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 17
rs 9.4285
cc 2
eloc 7
nc 2
nop 1
1
<?php
2
/**
3
 * @link    https://github.com/nnx-framework/doctrine-fixture-module
4
 * @author  Malofeykin Andrey  <[email protected]>
5
 */
6
namespace Nnx\JmsSerializerModule\DoctrineObjectEngine;
7
8
use Nnx\ModuleOptions\ModuleOptionsPluginManagerInterface;
9
use Zend\ServiceManager\AbstractPluginManager;
10
use Zend\ServiceManager\FactoryInterface;
11
use Zend\ServiceManager\ServiceLocatorInterface;
12
use \Nnx\JmsSerializerModule\Options\ModuleOptions;
13
use Interop\Container\ContainerInterface;
14
15
/**
16
 * Class ImportEngineFactory
17
 *
18
 * @package Nnx\JmsSerializerModule\DoctrineObjectEngine
19
 */
20
class ImportEngineFactory implements FactoryInterface
21
{
22
    /**
23
     * @inheritDoc
24
     * @throws \Zend\ServiceManager\Exception\ServiceNotFoundException
25
     */
26
    public function createService(ServiceLocatorInterface $serviceLocator)
27
    {
28
        $appServiceLocator = $serviceLocator instanceof AbstractPluginManager ? $serviceLocator->getServiceLocator() : $serviceLocator;
29
30
        /** @var ModuleOptionsPluginManagerInterface $moduleOptionsPluginManager */
31
        $moduleOptionsPluginManager = $appServiceLocator->get(ModuleOptionsPluginManagerInterface::class);
32
33
        /** @var ModuleOptions $moduleOptions */
34
        $moduleOptions = $moduleOptionsPluginManager->get(ModuleOptions::class);
35
36
        $entityLocatorServiceName = $moduleOptions->getEntityLocator();
37
38
        /** @var ContainerInterface $entityLocator */
39
        $entityLocator = $serviceLocator->get($entityLocatorServiceName);
40
41
        return new ImportEngine($entityLocator);
42
    }
43
}
44