Completed
Push — dev ( 1c6cdb...867b7a )
by Андрей
05:11
created

EntityMapBuilderControllerFactory::createService()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 12
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Importance

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