-
Notifications
You must be signed in to change notification settings - Fork 2
/
Module.php
97 lines (87 loc) · 3.66 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
91
92
93
94
95
96
97
<?php
namespace PhlyPaste;
use Zend\Captcha\Factory as CaptchaFactory;
class Module
{
public function getAutoloaderConfig()
{
return array(
'Zend\Loader\ClassMapAutoloader' => array(
__DIR__ . '/autoload_classmap.php',
),
'Zend\Loader\StandardAutoloader' => array(
'namespaces' => array(
__NAMESPACE__ => __DIR__ . '/src/' . __NAMESPACE__,
),
),
);
}
public function getConfig()
{
return include __DIR__ . '/config/module.config.php';
}
public function getServiceConfig()
{
return array('factories' => array(
'PhlyPaste\CaptchaService' => function ($services) {
$config = $services->get('config');
return CaptchaFactory::factory($config['phly_paste']['captcha']);
},
'PhlyPaste\FormFactory' => function ($services) {
$captcha = $services->get('PhlyPaste\Captcha');
$auth = null;
if ($services->has('PhlyPaste\AuthService')) {
$auth = $services->get('PhlyPaste\AuthService');
}
return new Model\Form($captcha, $auth);
},
'PhlyPaste\PasteTable' => function ($services) {
$config = $services->get('config');
$config = $config['phly_paste']['table_gateway'];
$adapter = $services->get('PhlyPaste\DbAdapter');
return new Model\PasteTable($adapter, $config['table']);
},
'PhlyPaste\TableGatewayService' => function ($services) {
$table = $services->get('PhlyPaste\TableGateway');
return new Model\TableGatewayPasteService($table);
},
'PhlyPaste\ArrayTokenService' => function ($services) {
$config = $services->get('config');
$tokens = $config['phly_paste']['tokens'];
return new Model\ArrayTokenService($tokens);
},
'PhlyPaste\JsonStrategy' => function ($services) {
$renderer = $services->get('ViewJsonRenderer');
$strategy = new View\JsonStrategy($renderer);
return $strategy;
},
));
}
public function getControllerConfig()
{
return array(
'factories' => array(
'PhlyPaste\Controller\Paste' => function ($controllers) {
$services = $controllers->getServiceLocator();
$formFactory = $services->get('PhlyPaste\FormFactory');
$pasteService = $services->get('PhlyPaste\PasteService');
$controller = new Controller\PasteController();
$controller->setFormFactory($formFactory);
$controller->setPasteService($pasteService);
return $controller;
},
'PhlyPaste\Controller\Api' => function ($controllers) {
$services = $controllers->getServiceLocator();
$formFactory = $services->get('PhlyPaste\FormFactory');
$pasteService = $services->get('PhlyPaste\PasteService');
$tokenService = $services->get('PhlyPaste\TokenService');
$controller = new Controller\ApiController();
$controller->setFormFactory($formFactory);
$controller->setPasteService($pasteService);
$controller->setTokenService($tokenService);
return $controller;
},
),
);
}
}