EntityMapBuilderControllerFactory::createService()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 15
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 15
rs 9.4285
cc 2
eloc 7
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
use Nnx\Doctrine\Utils\EntityMapCacheInterface;
13
14
15
/**
16
 * Class EntityMapBuilderController
17
 *
18
 * @package Nnx\Doctrine\Controller
19
 */
20
class EntityMapBuilderControllerFactory implements FactoryInterface
21
{
22
    /**
23
     * @inheritdoc
24
     *
25
     * @param ServiceLocatorInterface $serviceLocator
26
     *
27
     * @return EntityMapBuilderController
28
     *
29
     * @throws \Zend\ServiceManager\Exception\ServiceNotFoundException
30
     */
31
    public function createService(ServiceLocatorInterface $serviceLocator)
32
    {
33
        $appServiceLocator = $serviceLocator;
34
        if ($serviceLocator instanceof AbstractPluginManager) {
35
            $appServiceLocator = $serviceLocator->getServiceLocator();
36
        }
37
38
        /** @var DoctrineObjectManager $doctrineObjectManager */
39
        $doctrineObjectManager = $appServiceLocator->get(DoctrineObjectManager::class);
40
41
        /** @var EntityMapCacheInterface $entityMapCache */
42
        $entityMapCache = $appServiceLocator->get(EntityMapCacheInterface::class);
43
44
        return new EntityMapBuilderController($doctrineObjectManager, $entityMapCache);
45
    }
46
}
47