Completed
Push — refactor-entity-validators ( 9b4b77...c6627d )
by Stefano
13:07 queued 10:18
created

Module::getValidatorConfig()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 9
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 1.064

Importance

Changes 2
Bugs 1 Features 1
Metric Value
c 2
b 1
f 1
dl 0
loc 9
ccs 3
cts 5
cp 0.6
rs 9.6666
cc 1
eloc 5
nc 1
nop 0
crap 1.064
1
<?php
2
/**
3
 * @author Stefano Torresi (http://stefanotorresi.it)
4
 * @license See the file LICENSE.txt for copying permission.
5
 * ************************************************
6
 */
7
8
namespace Thorr\Persistence;
9
10
use Zend\ModuleManager\Feature;
11
use Zend\ModuleManager\Listener\ServiceListenerInterface;
12
use Zend\ModuleManager\ModuleManagerInterface;
13
use Zend\ServiceManager\ServiceManager;
14
15
class Module implements
16
    Feature\ValidatorProviderInterface,
17
    Feature\InitProviderInterface,
18
    Feature\ServiceProviderInterface
19
{
20
    /**
21
     * {@inheritdoc}
22
     */
23 4
    public function init(ModuleManagerInterface $moduleManager)
24
    {
25
        /** @var ServiceManager $serviceManager */
26
        $serviceManager = $moduleManager->getEvent()->getParam('ServiceManager');
0 ignored issues
show
Bug introduced by
The method getEvent() does not exist on Zend\ModuleManager\ModuleManagerInterface. Did you maybe mean getEventManager()?

This check marks calls to methods that do not seem to exist on an object.

This is most likely the result of a method being renamed without all references to it being renamed likewise.

Loading history...
27
28
        /** @var ServiceListenerInterface $serviceListener */
29
        $serviceListener = $serviceManager->get('ServiceListener');
30
31
        $serviceListener->addServiceManager(
32 4
            DataMapper\Manager\DataMapperManager::class,
33 4
            'thorr_persistence_dmm',
34 4
            DataMapper\Manager\DataMapperManagerConfigProviderInterface::class,
35 4
            'getDataMapperManagerConfig'
36
        );
37
    }
38
39
    /**
40
     * {@inheritdoc}
41
     */
42 4
    public function getServiceConfig()
43
    {
44
        return [
45
            'factories' => [
46
                DataMapper\Manager\DataMapperManager::class => DataMapper\Manager\DataMapperManagerFactory::class,
47
            ],
48
            'aliases' => [
49
                'DataMapperManager' => DataMapper\Manager\DataMapperManager::class,
50
            ],
51 4
        ];
52
    }
53
54
    /**
55
     * {@inheritdoc}
56
     */
57 4
    public function getValidatorConfig()
58
    {
59
        return [
60
            'factories' => [
61
                Validator\EntityExistsValidator::class    => new Factory\EntityValidatorFactory(Validator\EntityExistsValidator::class),
62
                Validator\EntityNotExistsValidator::class => new Factory\EntityValidatorFactory(Validator\EntityNotExistsValidator::class),
63 4
            ],
64 4
        ];
65
    }
66
}
67