1
|
|
|
<?php |
2
|
|
|
/* |
3
|
|
|
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS |
4
|
|
|
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT |
5
|
|
|
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR |
6
|
|
|
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT |
7
|
|
|
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |
8
|
|
|
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |
9
|
|
|
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
10
|
|
|
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
11
|
|
|
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
12
|
|
|
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
13
|
|
|
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
14
|
|
|
* |
15
|
|
|
* This software consists of voluntary contributions made by many individuals |
16
|
|
|
* and is licensed under the MIT license. For more information, see |
17
|
|
|
* <http://www.doctrine-project.org>. |
18
|
|
|
*/ |
19
|
|
|
|
20
|
|
|
namespace DoctrineModule; |
21
|
|
|
|
22
|
|
|
/** |
23
|
|
|
* Config provider for DoctrineORMModule config |
24
|
|
|
* |
25
|
|
|
* @license MIT |
26
|
|
|
* @link www.doctrine-project.org |
27
|
|
|
* @author James Titcumb <[email protected]> |
28
|
|
|
*/ |
29
|
|
|
class ConfigProvider |
30
|
|
|
{ |
31
|
|
|
/** |
32
|
|
|
* @return array |
33
|
|
|
*/ |
34
|
1 |
|
public function __invoke() |
35
|
|
|
{ |
36
|
|
|
return [ |
37
|
1 |
|
'doctrine' => $this->getDoctrineConfig(), |
38
|
1 |
|
'doctrine_factories' => $this->getDoctrineFactoryConfig(), |
39
|
1 |
|
'dependencies' => $this->getDependencyConfig(), |
40
|
1 |
|
'controllers' => $this->getControllerConfig(), |
41
|
1 |
|
'route_manager' => $this->getRouteManagerConfig(), |
42
|
1 |
|
'console' => $this->getConsoleConfig(), |
43
|
1 |
|
'validators' => $this->getValidatorConfig(), |
44
|
1 |
|
]; |
45
|
|
|
} |
46
|
|
|
|
47
|
|
|
/** |
48
|
|
|
* Return application-level dependency configuration |
49
|
|
|
* |
50
|
|
|
* @return array |
51
|
|
|
*/ |
52
|
31 |
|
public function getDependencyConfig() |
53
|
|
|
{ |
54
|
|
|
return [ |
55
|
|
|
'invokables' => [ |
56
|
31 |
|
'DoctrineModule\Authentication\Storage\Session' => 'Zend\Authentication\Storage\Session', |
57
|
31 |
|
], |
58
|
|
|
'factories' => [ |
59
|
31 |
|
'doctrine.cli' => 'DoctrineModule\Service\CliFactory', |
60
|
31 |
|
], |
61
|
|
|
'abstract_factories' => [ |
62
|
31 |
|
'DoctrineModule' => 'DoctrineModule\ServiceFactory\AbstractDoctrineServiceFactory', |
63
|
31 |
|
], |
64
|
31 |
|
]; |
65
|
|
|
} |
66
|
|
|
|
67
|
|
|
/** |
68
|
|
|
* Return controller configuration |
69
|
|
|
* |
70
|
|
|
* @return array |
71
|
|
|
*/ |
72
|
31 |
|
public function getControllerConfig() |
73
|
|
|
{ |
74
|
|
|
return [ |
75
|
|
|
'factories' => [ |
76
|
31 |
|
'DoctrineModule\Controller\Cli' => 'DoctrineModule\Service\CliControllerFactory', |
77
|
31 |
|
], |
78
|
31 |
|
]; |
79
|
|
|
} |
80
|
|
|
|
81
|
|
|
/** |
82
|
|
|
* Return route manager configuration |
83
|
|
|
* |
84
|
|
|
* @return array |
85
|
|
|
*/ |
86
|
31 |
|
public function getRouteManagerConfig() |
87
|
|
|
{ |
88
|
|
|
return [ |
89
|
|
|
'factories' => [ |
90
|
31 |
|
'symfony_cli' => 'DoctrineModule\Service\SymfonyCliRouteFactory', |
91
|
31 |
|
], |
92
|
31 |
|
]; |
93
|
|
|
} |
94
|
|
|
|
95
|
|
|
/** |
96
|
|
|
* Return configuration for console routes |
97
|
|
|
* |
98
|
|
|
* @return array |
99
|
|
|
*/ |
100
|
31 |
|
public function getConsoleConfig() |
101
|
|
|
{ |
102
|
|
|
return [ |
103
|
|
|
'router' => [ |
104
|
|
|
'routes' => [ |
105
|
|
|
'doctrine_cli' => [ |
106
|
31 |
|
'type' => 'symfony_cli', |
107
|
31 |
|
], |
108
|
31 |
|
], |
109
|
31 |
|
], |
110
|
31 |
|
]; |
111
|
|
|
} |
112
|
|
|
|
113
|
|
|
/** |
114
|
|
|
* Default configuration for Doctrine module |
115
|
|
|
* |
116
|
|
|
* @return array |
117
|
|
|
*/ |
118
|
31 |
|
public function getDoctrineConfig() |
119
|
|
|
{ |
120
|
|
|
return [ |
121
|
|
|
'cache' => [ |
122
|
|
|
'apc' => [ |
123
|
31 |
|
'class' => 'Doctrine\Common\Cache\ApcCache', |
124
|
31 |
|
'namespace' => 'DoctrineModule', |
125
|
31 |
|
], |
126
|
|
|
'apcu' => [ |
127
|
31 |
|
'class' => 'Doctrine\Common\Cache\ApcuCache', |
128
|
31 |
|
'namespace' => 'DoctrineModule', |
129
|
31 |
|
], |
130
|
|
|
'array' => [ |
131
|
31 |
|
'class' => 'Doctrine\Common\Cache\ArrayCache', |
132
|
31 |
|
'namespace' => 'DoctrineModule', |
133
|
31 |
|
], |
134
|
|
|
'filesystem' => [ |
135
|
31 |
|
'class' => 'Doctrine\Common\Cache\FilesystemCache', |
136
|
31 |
|
'directory' => 'data/DoctrineModule/cache', |
137
|
31 |
|
'namespace' => 'DoctrineModule', |
138
|
31 |
|
], |
139
|
|
|
'memcache' => [ |
140
|
31 |
|
'class' => 'Doctrine\Common\Cache\MemcacheCache', |
141
|
31 |
|
'instance' => 'my_memcache_alias', |
142
|
31 |
|
'namespace' => 'DoctrineModule', |
143
|
31 |
|
], |
144
|
|
|
'memcached' => [ |
145
|
31 |
|
'class' => 'Doctrine\Common\Cache\MemcachedCache', |
146
|
31 |
|
'instance' => 'my_memcached_alias', |
147
|
31 |
|
'namespace' => 'DoctrineModule', |
148
|
31 |
|
], |
149
|
|
|
'predis' => [ |
150
|
31 |
|
'class' => 'Doctrine\Common\Cache\PredisCache', |
151
|
31 |
|
'instance' => 'my_predis_alias', |
152
|
31 |
|
'namespace' => 'DoctrineModule', |
153
|
31 |
|
], |
154
|
|
|
'redis' => [ |
155
|
31 |
|
'class' => 'Doctrine\Common\Cache\RedisCache', |
156
|
31 |
|
'instance' => 'my_redis_alias', |
157
|
31 |
|
'namespace' => 'DoctrineModule', |
158
|
31 |
|
], |
159
|
|
|
'wincache' => [ |
160
|
31 |
|
'class' => 'Doctrine\Common\Cache\WinCacheCache', |
161
|
31 |
|
'namespace' => 'DoctrineModule', |
162
|
31 |
|
], |
163
|
|
|
'xcache' => [ |
164
|
31 |
|
'class' => 'Doctrine\Common\Cache\XcacheCache', |
165
|
31 |
|
'namespace' => 'DoctrineModule', |
166
|
31 |
|
], |
167
|
|
|
'zenddata' => [ |
168
|
31 |
|
'class' => 'Doctrine\Common\Cache\ZendDataCache', |
169
|
31 |
|
'namespace' => 'DoctrineModule', |
170
|
31 |
|
], |
171
|
31 |
|
], |
172
|
|
|
|
173
|
|
|
//These authentication settings are a hack to tide things over until version 1.0 |
174
|
|
|
//Normall doctrineModule should have no mention of odm or orm |
175
|
|
|
'authentication' => [ |
176
|
|
|
//default authentication options should be set in either the odm or orm modules |
177
|
31 |
|
'odm_default' => [], |
178
|
31 |
|
'orm_default' => [], |
179
|
31 |
|
], |
180
|
|
|
'authenticationadapter' => [ |
181
|
31 |
|
'odm_default' => true, |
182
|
31 |
|
'orm_default' => true, |
183
|
31 |
|
], |
184
|
|
|
'authenticationstorage' => [ |
185
|
31 |
|
'odm_default' => true, |
186
|
31 |
|
'orm_default' => true, |
187
|
31 |
|
], |
188
|
|
|
'authenticationservice' => [ |
189
|
31 |
|
'odm_default' => true, |
190
|
31 |
|
'orm_default' => true, |
191
|
31 |
|
], |
192
|
31 |
|
]; |
193
|
|
|
} |
194
|
|
|
|
195
|
|
|
/** |
196
|
|
|
* Factory mappings - used to define which factory to use to instantiate a particular doctrine service type |
197
|
|
|
* |
198
|
|
|
* @return array |
199
|
|
|
*/ |
200
|
31 |
|
public function getDoctrineFactoryConfig() |
201
|
|
|
{ |
202
|
|
|
return [ |
203
|
31 |
|
'cache' => 'DoctrineModule\Service\CacheFactory', |
204
|
31 |
|
'eventmanager' => 'DoctrineModule\Service\EventManagerFactory', |
205
|
31 |
|
'driver' => 'DoctrineModule\Service\DriverFactory', |
206
|
31 |
|
'authenticationadapter' => 'DoctrineModule\Service\Authentication\AdapterFactory', |
207
|
31 |
|
'authenticationstorage' => 'DoctrineModule\Service\Authentication\StorageFactory', |
208
|
31 |
|
'authenticationservice' => 'DoctrineModule\Service\Authentication\AuthenticationServiceFactory', |
209
|
31 |
|
]; |
210
|
|
|
} |
211
|
|
|
|
212
|
|
|
/** |
213
|
|
|
* @return array |
214
|
|
|
*/ |
215
|
31 |
|
public function getValidatorConfig() |
216
|
|
|
{ |
217
|
|
|
return [ |
218
|
|
|
'aliases' => [ |
219
|
31 |
|
'DoctrineNoObjectExists' => Validator\NoObjectExists::class, |
220
|
31 |
|
'DoctrineObjectExists' => Validator\ObjectExists::class, |
221
|
31 |
|
'DoctrineUniqueObject' => Validator\UniqueObject::class, |
222
|
31 |
|
], |
223
|
|
|
'factories' => [ |
224
|
31 |
|
Validator\NoObjectExists::class => Validator\Service\NoObjectExistsFactory::class, |
225
|
31 |
|
Validator\ObjectExists::class => Validator\Service\ObjectExistsFactory::class, |
226
|
31 |
|
Validator\UniqueObject::class => Validator\Service\UniqueObjectFactory::class, |
227
|
31 |
|
], |
228
|
31 |
|
]; |
229
|
|
|
} |
230
|
|
|
} |
231
|
|
|
|