-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathModule.php
90 lines (81 loc) · 3.09 KB
/
Module.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
<?php
namespace RoLocations;
use T4webBase\Domain\Service\BaseFinder;
use Zend\Mvc\Controller\ControllerManager;
use Zend\ModuleManager\Feature\ControllerProviderInterface;
use Zend\ModuleManager\Feature\ServiceProviderInterface;
use Zend\ModuleManager\Feature\AutoloaderProviderInterface;
use Zend\ModuleManager\Feature\ConsoleUsageProviderInterface;
use Zend\Console\Adapter\AdapterInterface as ConsoleAdapterInterface;
use Zend\ServiceManager\ServiceManager;
class Module implements AutoloaderProviderInterface, ConsoleUsageProviderInterface, ControllerProviderInterface, ServiceProviderInterface
{
public function getConfig()
{
return include __DIR__ . '/config/module.config.php';
}
public function getAutoloaderConfig()
{
return [
'Zend\Loader\StandardAutoloader' => [
'namespaces' => [
__NAMESPACE__ => __DIR__ . '/src/' . __NAMESPACE__,
],
],
];
}
public function getConsoleUsage(ConsoleAdapterInterface $console)
{
return [
'locations init' => 'Initialize module',
];
}
public function getServiceConfig()
{
return [
'factories' => [
// countries
'RoLocations\Countries\Service\Finder' => function (ServiceManager $sm) {
return new BaseFinder(
$sm->get('RoLocations\Countries\Repository\DbRepository'),
$sm->get('RoLocations\Countries\Criteria\CriteriaFactory')
);
},
// regions
'RoLocations\Regions\Service\Finder' => function (ServiceManager $sm) {
return new BaseFinder(
$sm->get('RoLocations\Regions\Repository\DbRepository'),
$sm->get('RoLocations\Regions\Criteria\CriteriaFactory')
);
},
// cities
'RoLocations\Cities\Service\Finder' => function (ServiceManager $sm) {
return new BaseFinder(
$sm->get('RoLocations\Cities\Repository\DbRepository'),
$sm->get('RoLocations\Cities\Criteria\CriteriaFactory')
);
},
],
'invokables' => [
],
];
}
public function getControllerConfig()
{
return [
'factories' => [
'RoLocations\Controller\User\IndexAjax' => function (ControllerManager $cm) {
$sm = $cm->getServiceLocator();
return new Controller\User\IndexAjaxController(
$sm->get('RoLocations\Countries\Service\Finder'),
$sm->get('RoLocations\Regions\Service\Finder'),
$sm->get('RoLocations\Cities\Service\Finder')
);
},
],
'invokables' => [
'RoLocations\Controller\Console\Init' => 'RoLocations\Controller\Console\InitController',
],
];
}
}