Completed
Push — master ( 172e29...c7a288 )
by Андрей
04:37 queued 01:58
created

ObjectManagerServiceFactory::createService()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 10
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

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