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 DoctrineORMModule; |
21
|
|
|
|
22
|
|
|
use Doctrine\Common\Persistence\Mapping\Driver\MappingDriverChain; |
23
|
|
|
use Doctrine\DBAL\Tools\Console\Command as DBALCommand; |
24
|
|
|
use Doctrine\ORM\Tools\Console\Command as ORMCommand; |
25
|
|
|
use DoctrineModule\Form\Element; |
26
|
|
|
use DoctrineModule\Stdlib\Hydrator\DoctrineObject; |
27
|
|
|
use DoctrineORMModule\Yuml\YumlController; |
28
|
|
|
use DoctrineORMModule\Yuml\YumlControllerFactory; |
29
|
|
|
use Zend\Router\Http\Literal; |
30
|
|
|
use Zend\ServiceManager\Factory\InvokableFactory; |
31
|
|
|
|
32
|
|
|
class ConfigProvider |
33
|
|
|
{ |
34
|
|
|
/** |
35
|
|
|
* Return general-purpose zend-i18n configuration. |
36
|
|
|
* |
37
|
|
|
* @return array |
38
|
|
|
*/ |
39
|
|
|
public function __invoke() |
40
|
|
|
{ |
41
|
|
|
return [ |
42
|
|
|
'controllers' => $this->getControllerConfig(), |
43
|
|
|
'dependencies' => $this->getDependencyConfig(), |
44
|
|
|
'doctrine' => $this->getDoctrineConfig(), |
45
|
|
|
'doctrine_factories' => $this->getDoctrineFactoryConfig(), |
46
|
|
|
'form_elements' => $this->getFormElementConfig(), |
47
|
|
|
'hydrators' => $this->getHydratorConfig(), |
48
|
|
|
'router' => $this->getRouterConfig(), |
49
|
|
|
'view_manager' => $this->getViewManagerConfig(), |
50
|
|
|
'zenddevelopertools' => $this->getZendDeveloperToolConfig(), |
51
|
|
|
]; |
52
|
|
|
} |
53
|
|
|
|
54
|
|
|
/** |
55
|
|
|
* @return array |
56
|
|
|
*/ |
57
|
56 |
|
public function getControllerConfig() |
58
|
|
|
{ |
59
|
|
|
return [ |
60
|
|
|
'factories' => [ |
61
|
56 |
|
YumlController::class => YumlControllerFactory::class, |
62
|
56 |
|
], |
63
|
56 |
|
]; |
64
|
|
|
} |
65
|
|
|
|
66
|
|
|
/** |
67
|
|
|
* Return application-level dependency configuration. |
68
|
|
|
* |
69
|
|
|
* @return array |
70
|
|
|
*/ |
71
|
56 |
|
public function getDependencyConfig() |
72
|
|
|
{ |
73
|
|
|
return [ |
74
|
|
|
'aliases' => [ |
75
|
|
|
// DBAL commands |
76
|
56 |
|
'doctrine.dbal_cmd.runsql' => DBALCommand\RunSqlCommand::class, |
77
|
56 |
|
'doctrine.dbal_cmd.import' => DBALCommand\ImportCommand::class, |
78
|
|
|
// ORM Commands |
79
|
56 |
|
'doctrine.orm_cmd.clear_cache_metadata' => ORMCommand\ClearCache\MetadataCommand::class, |
80
|
56 |
|
'doctrine.orm_cmd.clear_cache_result' => ORMCommand\ClearCache\ResultCommand::class, |
81
|
56 |
|
'doctrine.orm_cmd.clear_cache_query' => ORMCommand\ClearCache\QueryCommand::class, |
82
|
56 |
|
'doctrine.orm_cmd.schema_tool_create' => ORMCommand\SchemaTool\CreateCommand::class, |
83
|
56 |
|
'doctrine.orm_cmd.schema_tool_update' => ORMCommand\SchemaTool\UpdateCommand::class, |
84
|
56 |
|
'doctrine.orm_cmd.schema_tool_drop' => ORMCommand\SchemaTool\DropCommand::class, |
85
|
56 |
|
'doctrine.orm_cmd.convert_d1_schema' => ORMCommand\ConvertDoctrine1SchemaCommand::class, |
86
|
56 |
|
'doctrine.orm_cmd.generate_entities' => ORMCommand\GenerateEntitiesCommand::class, |
87
|
56 |
|
'doctrine.orm_cmd.generate_proxies' => ORMCommand\GenerateProxiesCommand::class, |
88
|
56 |
|
'doctrine.orm_cmd.convert_mapping' => ORMCommand\ConvertMappingCommand::class, |
89
|
56 |
|
'doctrine.orm_cmd.run_dql' => ORMCommand\RunDqlCommand::class, |
90
|
56 |
|
'doctrine.orm_cmd.validate_schema' => ORMCommand\ValidateSchemaCommand::class, |
91
|
56 |
|
'doctrine.orm_cmd.info' => ORMCommand\InfoCommand::class, |
92
|
56 |
|
'doctrine.orm_cmd.ensure_production_settings' => ORMCommand\EnsureProductionSettingsCommand::class, |
93
|
56 |
|
'doctrine.orm_cmd.generate_repositories' => ORMCommand\GenerateRepositoriesCommand::class, |
94
|
56 |
|
], |
95
|
|
|
'factories' => [ |
96
|
56 |
|
'Doctrine\ORM\EntityManager' => Service\EntityManagerAliasCompatFactory::class, |
97
|
56 |
|
DBALCommand\RunSqlCommand::class => InvokableFactory::class, |
98
|
56 |
|
DBALCommand\ImportCommand::class => InvokableFactory::class, |
99
|
56 |
|
ORMCommand\ClearCache\MetadataCommand::class => InvokableFactory::class, |
100
|
56 |
|
ORMCommand\ClearCache\ResultCommand::class => InvokableFactory::class, |
101
|
56 |
|
ORMCommand\ClearCache\QueryCommand::class => InvokableFactory::class, |
102
|
56 |
|
ORMCommand\SchemaTool\CreateCommand::class => InvokableFactory::class, |
103
|
56 |
|
ORMCommand\SchemaTool\UpdateCommand::class => InvokableFactory::class, |
104
|
56 |
|
ORMCommand\SchemaTool\DropCommand::class => InvokableFactory::class, |
105
|
56 |
|
ORMCommand\ConvertDoctrine1SchemaCommand::class => InvokableFactory::class, |
106
|
56 |
|
ORMCommand\GenerateEntitiesCommand::class => InvokableFactory::class, |
107
|
56 |
|
ORMCommand\GenerateProxiesCommand::class => InvokableFactory::class, |
108
|
56 |
|
ORMCommand\ConvertMappingCommand::class => InvokableFactory::class, |
109
|
56 |
|
ORMCommand\RunDqlCommand::class => InvokableFactory::class, |
110
|
56 |
|
ORMCommand\ValidateSchemaCommand::class => InvokableFactory::class, |
111
|
56 |
|
ORMCommand\InfoCommand::class => InvokableFactory::class, |
112
|
56 |
|
ORMCommand\EnsureProductionSettingsCommand::class => InvokableFactory::class, |
113
|
56 |
|
ORMCommand\GenerateRepositoriesCommand::class => InvokableFactory::class, |
114
|
56 |
|
], |
115
|
56 |
|
]; |
116
|
|
|
} |
117
|
|
|
|
118
|
|
|
/** |
119
|
|
|
* @return array |
120
|
|
|
*/ |
121
|
56 |
|
public function getDoctrineConfig() |
122
|
|
|
{ |
123
|
|
|
return [ |
124
|
|
|
'connection' => [ |
125
|
|
|
// Configuration for service `doctrine.connection.orm_default` service |
126
|
|
|
'orm_default' => [ |
127
|
|
|
// configuration instance to use. The retrieved service name will |
128
|
|
|
// be `doctrine.configuration.$thisSetting` |
129
|
56 |
|
'configuration' => 'orm_default', |
130
|
|
|
|
131
|
|
|
// event manager instance to use. The retrieved service name will |
132
|
|
|
// be `doctrine.eventmanager.$thisSetting` |
133
|
56 |
|
'eventmanager' => 'orm_default', |
134
|
|
|
|
135
|
|
|
// connection parameters, see |
136
|
|
|
// http://docs.doctrine-project.org/projects/doctrine-dbal/en/latest/reference/configuration.html |
137
|
|
|
'params' => [ |
138
|
56 |
|
'host' => 'localhost', |
139
|
56 |
|
'port' => '3306', |
140
|
56 |
|
'user' => 'username', |
141
|
56 |
|
'password' => 'password', |
142
|
56 |
|
'dbname' => 'database', |
143
|
56 |
|
], |
144
|
56 |
|
], |
145
|
56 |
|
], |
146
|
|
|
|
147
|
|
|
// Configuration details for the ORM. |
148
|
|
|
// See http://docs.doctrine-project.org/en/latest/reference/configuration.html |
149
|
|
|
'configuration' => [ |
150
|
|
|
// Configuration for service `doctrine.configuration.orm_default` service |
151
|
|
|
'orm_default' => [ |
152
|
|
|
// metadata cache instance to use. The retrieved service name will |
153
|
|
|
// be `doctrine.cache.$thisSetting` |
154
|
56 |
|
'metadata_cache' => 'array', |
155
|
|
|
|
156
|
|
|
// DQL queries parsing cache instance to use. The retrieved service |
157
|
|
|
// name will be `doctrine.cache.$thisSetting` |
158
|
56 |
|
'query_cache' => 'array', |
159
|
|
|
|
160
|
|
|
// ResultSet cache to use. The retrieved service name will be |
161
|
|
|
// `doctrine.cache.$thisSetting` |
162
|
56 |
|
'result_cache' => 'array', |
163
|
|
|
|
164
|
|
|
// Hydration cache to use. The retrieved service name will be |
165
|
|
|
// `doctrine.cache.$thisSetting` |
166
|
56 |
|
'hydration_cache' => 'array', |
167
|
|
|
|
168
|
|
|
// Mapping driver instance to use. Change this only if you don't want |
169
|
|
|
// to use the default chained driver. The retrieved service name will |
170
|
|
|
// be `doctrine.driver.$thisSetting` |
171
|
56 |
|
'driver' => 'orm_default', |
172
|
|
|
|
173
|
|
|
// Generate proxies automatically (turn off for production) |
174
|
56 |
|
'generate_proxies' => true, |
175
|
|
|
|
176
|
|
|
// directory where proxies will be stored. By default, this is in |
177
|
|
|
// the `data` directory of your application |
178
|
56 |
|
'proxy_dir' => 'data/DoctrineORMModule/Proxy', |
179
|
|
|
|
180
|
|
|
// namespace for generated proxy classes |
181
|
56 |
|
'proxy_namespace' => 'DoctrineORMModule\Proxy', |
182
|
|
|
|
183
|
|
|
// SQL filters. See http://docs.doctrine-project.org/en/latest/reference/filters.html |
184
|
56 |
|
'filters' => [], |
185
|
|
|
|
186
|
|
|
// Custom DQL functions. |
187
|
|
|
// You can grab common MySQL ones at https://github.com/beberlei/DoctrineExtensions |
188
|
|
|
// Further docs at |
189
|
|
|
// http://docs.doctrine-project.org/en/latest/cookbook/dql-user-defined-functions.html |
190
|
56 |
|
'datetime_functions' => [], |
191
|
56 |
|
'string_functions' => [], |
192
|
56 |
|
'numeric_functions' => [], |
193
|
|
|
|
194
|
|
|
// Second level cache configuration (see doc to learn about configuration) |
195
|
56 |
|
'second_level_cache' => [], |
196
|
56 |
|
], |
197
|
56 |
|
], |
198
|
|
|
|
199
|
|
|
// Metadata Mapping driver configuration |
200
|
|
|
'driver' => [ |
201
|
|
|
// Configuration for service `doctrine.driver.orm_default` service |
202
|
|
|
'orm_default' => [ |
203
|
|
|
// By default, the ORM module uses a driver chain. This allows multiple |
204
|
|
|
// modules to define their own entities |
205
|
56 |
|
'class' => MappingDriverChain::class, |
206
|
|
|
|
207
|
|
|
// Map of driver names to be used within this driver chain, indexed by |
208
|
|
|
// entity namespace |
209
|
56 |
|
'drivers' => [], |
210
|
56 |
|
], |
211
|
56 |
|
], |
212
|
|
|
|
213
|
|
|
// Entity Manager instantiation settings |
214
|
|
|
'entitymanager' => [ |
215
|
|
|
// configuration for the `doctrine.entitymanager.orm_default` service |
216
|
|
|
'orm_default' => [ |
217
|
|
|
// connection instance to use. The retrieved service name will |
218
|
|
|
// be `doctrine.connection.$thisSetting` |
219
|
56 |
|
'connection' => 'orm_default', |
220
|
|
|
|
221
|
|
|
// configuration instance to use. The retrieved service name will |
222
|
|
|
// be `doctrine.configuration.$thisSetting` |
223
|
56 |
|
'configuration' => 'orm_default', |
224
|
56 |
|
], |
225
|
56 |
|
], |
226
|
|
|
|
227
|
|
|
'eventmanager' => [ |
228
|
|
|
// configuration for the `doctrine.eventmanager.orm_default` service |
229
|
56 |
|
'orm_default' => [], |
230
|
56 |
|
], |
231
|
|
|
|
232
|
|
|
// SQL logger collector, used when ZendDeveloperTools and its toolbar are active |
233
|
|
|
'sql_logger_collector' => [ |
234
|
|
|
// configuration for the `doctrine.sql_logger_collector.orm_default` service |
235
|
56 |
|
'orm_default' => [], |
236
|
56 |
|
], |
237
|
|
|
|
238
|
|
|
// mappings collector, used when ZendDeveloperTools and its toolbar are active |
239
|
|
|
'mapping_collector' => [ |
240
|
|
|
// configuration for the `doctrine.sql_logger_collector.orm_default` service |
241
|
56 |
|
'orm_default' => [], |
242
|
56 |
|
], |
243
|
|
|
|
244
|
|
|
// form annotation builder configuration |
245
|
|
|
'formannotationbuilder' => [ |
246
|
|
|
// Configuration for service `doctrine.formannotationbuilder.orm_default` service |
247
|
56 |
|
'orm_default' => [], |
248
|
56 |
|
], |
249
|
|
|
|
250
|
|
|
// entity resolver configuration, allows mapping associations to interfaces |
251
|
|
|
'entity_resolver' => [ |
252
|
|
|
// configuration for the `doctrine.entity_resolver.orm_default` service |
253
|
56 |
|
'orm_default' => [], |
254
|
56 |
|
], |
255
|
|
|
|
256
|
|
|
// authentication service configuration |
257
|
|
|
'authentication' => [ |
258
|
|
|
// configuration for the `doctrine.authentication.orm_default` authentication service |
259
|
|
|
'orm_default' => [ |
260
|
|
|
// name of the object manager to use. By default, the EntityManager is used |
261
|
56 |
|
'objectManager' => 'doctrine.entitymanager.orm_default', |
262
|
|
|
//'identityClass' => 'Application\Model\User', |
263
|
|
|
//'identityProperty' => 'username', |
264
|
|
|
//'credentialProperty' => 'password', |
265
|
56 |
|
], |
266
|
56 |
|
], |
267
|
|
|
|
268
|
|
|
// migrations configuration |
269
|
|
|
'migrations_configuration' => [ |
270
|
|
|
'orm_default' => [ |
271
|
56 |
|
'directory' => 'data/DoctrineORMModule/Migrations', |
272
|
56 |
|
'name' => 'Doctrine Database Migrations', |
273
|
56 |
|
'namespace' => 'DoctrineORMModule\Migrations', |
274
|
56 |
|
'table' => 'migrations', |
275
|
56 |
|
'column' => 'version', |
276
|
56 |
|
], |
277
|
56 |
|
], |
278
|
|
|
|
279
|
|
|
// migrations commands base config |
280
|
|
|
'migrations_cmd' => [ |
281
|
56 |
|
'generate' => [], |
282
|
56 |
|
'execute' => [], |
283
|
56 |
|
'migrate' => [], |
284
|
56 |
|
'status' => [], |
285
|
56 |
|
'version' => [], |
286
|
56 |
|
'diff' => [], |
287
|
56 |
|
'latest' => [], |
288
|
56 |
|
], |
289
|
56 |
|
]; |
290
|
|
|
} |
291
|
|
|
|
292
|
|
|
/** |
293
|
|
|
* @return array |
294
|
|
|
*/ |
295
|
56 |
|
public function getDoctrineFactoryConfig() |
296
|
|
|
{ |
297
|
|
|
return [ |
298
|
56 |
|
'connection' => Service\DBALConnectionFactory::class, |
299
|
56 |
|
'configuration' => Service\ConfigurationFactory::class, |
300
|
56 |
|
'entitymanager' => Service\EntityManagerFactory::class, |
301
|
56 |
|
'entity_resolver' => Service\EntityResolverFactory::class, |
302
|
56 |
|
'sql_logger_collector' => Service\SQLLoggerCollectorFactory::class, |
303
|
56 |
|
'mapping_collector' => Service\MappingCollectorFactory::class, |
304
|
56 |
|
'formannotationbuilder' => Service\FormAnnotationBuilderFactory::class, |
305
|
56 |
|
'migrations_configuration' => Service\MigrationsConfigurationFactory::class, |
306
|
56 |
|
'migrations_cmd' => Service\MigrationsCommandFactory::class, |
307
|
56 |
|
]; |
308
|
|
|
} |
309
|
|
|
|
310
|
56 |
|
public function getFormElementConfig() |
311
|
|
|
{ |
312
|
|
|
return [ |
313
|
|
|
'aliases' => [ |
314
|
56 |
|
'objectselect' => Element\ObjectSelect::class, |
315
|
56 |
|
'objectradio' => Element\ObjectRadio::class, |
316
|
56 |
|
'objectmulticheckbox' => Element\ObjectMultiCheckbox::class, |
317
|
56 |
|
], |
318
|
|
|
'factories' => [ |
319
|
56 |
|
Element\ObjectSelect::class => Service\ObjectSelectFactory::class, |
320
|
56 |
|
Element\ObjectRadio::class => Service\ObjectRadioFactory::class, |
321
|
56 |
|
Element\ObjectMultiCheckbox::class => Service\ObjectMultiCheckboxFactory::class, |
322
|
56 |
|
], |
323
|
56 |
|
]; |
324
|
|
|
} |
325
|
|
|
|
326
|
|
|
/** |
327
|
|
|
* @return array |
328
|
|
|
*/ |
329
|
56 |
|
public function getHydratorConfig() |
330
|
|
|
{ |
331
|
|
|
return [ |
332
|
|
|
'factories' => [ |
333
|
56 |
|
DoctrineObject::class => Service\DoctrineObjectHydratorFactory::class, |
334
|
56 |
|
], |
335
|
56 |
|
]; |
336
|
|
|
} |
337
|
|
|
|
338
|
|
|
/** |
339
|
|
|
* @return array |
340
|
|
|
*/ |
341
|
56 |
|
public function getRouterConfig() |
342
|
|
|
{ |
343
|
|
|
return [ |
344
|
|
|
'routes' => [ |
345
|
|
|
'doctrine_orm_module_yuml' => [ |
346
|
56 |
|
'type' => Literal::class, |
347
|
|
|
'options' => [ |
348
|
56 |
|
'route' => '/ocra_service_manager_yuml', |
349
|
|
|
'defaults' => [ |
350
|
56 |
|
'controller' => Yuml\YumlController::class, |
351
|
56 |
|
'action' => 'index', |
352
|
56 |
|
], |
353
|
56 |
|
], |
354
|
56 |
|
], |
355
|
56 |
|
], |
356
|
56 |
|
]; |
357
|
|
|
} |
358
|
|
|
|
359
|
|
|
/** |
360
|
|
|
* @return array |
361
|
|
|
*/ |
362
|
56 |
|
public function getViewManagerConfig() |
363
|
|
|
{ |
364
|
|
|
return [ |
365
|
|
|
'template_map' => [ |
366
|
|
|
'zend-developer-tools/toolbar/doctrine-orm-queries' |
367
|
56 |
|
=> __DIR__ . '/../view/zend-developer-tools/toolbar/doctrine-orm-queries.phtml', |
368
|
|
|
'zend-developer-tools/toolbar/doctrine-orm-mappings' |
369
|
56 |
|
=> __DIR__ . '/../view/zend-developer-tools/toolbar/doctrine-orm-mappings.phtml', |
370
|
56 |
|
], |
371
|
56 |
|
]; |
372
|
|
|
} |
373
|
|
|
|
374
|
|
|
/** |
375
|
|
|
* @return array |
376
|
|
|
*/ |
377
|
56 |
|
public function getZendDeveloperToolConfig() |
378
|
|
|
{ |
379
|
|
|
return [ |
380
|
|
|
'profiler' => [ |
381
|
|
|
'collectors' => [ |
382
|
56 |
|
'doctrine.sql_logger_collector.orm_default' => 'doctrine.sql_logger_collector.orm_default', |
383
|
56 |
|
'doctrine.mapping_collector.orm_default' => 'doctrine.mapping_collector.orm_default', |
384
|
56 |
|
], |
385
|
56 |
|
], |
386
|
|
|
'toolbar' => [ |
387
|
|
|
'entries' => [ |
388
|
56 |
|
'doctrine.sql_logger_collector.orm_default' => 'zend-developer-tools/toolbar/doctrine-orm-queries', |
389
|
56 |
|
'doctrine.mapping_collector.orm_default' => 'zend-developer-tools/toolbar/doctrine-orm-mappings', |
390
|
56 |
|
], |
391
|
56 |
|
], |
392
|
56 |
|
]; |
393
|
|
|
} |
394
|
|
|
} |
395
|
|
|
|