File tree Expand file tree Collapse file tree 3 files changed +34
-0
lines changed
src/Dflydev/Pimple/Provider/DoctrineOrm
tests/Dflydev/Pimple/Provider/DoctrineOrm Expand file tree Collapse file tree 3 files changed +34
-0
lines changed Original file line number Diff line number Diff line change @@ -212,6 +212,9 @@ Configuration
212212 * ** resources_namespace** : A namespaceish path to where the mapping
213213 files are located. Example: ` Path\To\Foo\Resources\mappings `
214214
215+ Each mapping definition can have the following optional options:
216+ * ** alias** (Default: null): Set the alias for the entity namespace.
217+
215218 Each ** annotation** mapping may also specify the following options:
216219 * ** use_simple_annotation_reader** (Default: true):
217220 If ` true ` , only simple notations like ` @Entity ` will work.
Original file line number Diff line number Diff line change @@ -129,6 +129,10 @@ public function register(\Pimple $app)
129129 $ entity ['path ' ] = $ app ['psr0_resource_locator ' ]->findFirstDirectory ($ entity ['resources_namespace ' ]);
130130 }
131131
132+ if (isset ($ entity ['alias ' ])) {
133+ $ config ->addEntityNamespace ($ entity ['alias ' ], $ entity ['namespace ' ]);
134+ }
135+
132136 switch ($ entity ['type ' ]) {
133137 case 'annotation ' :
134138 $ useSimpleAnnotationReader =
Original file line number Diff line number Diff line change @@ -282,4 +282,31 @@ public function testInvalidMappingAsOption()
282282
283283 $ app ['orm.ems.config ' ];
284284 }
285+
286+ /**
287+ * Test if namespace alias can be set through the mapping options
288+ */
289+ public function testMappingAlias ()
290+ {
291+ $ app = $ this ->createMockDefaultApp ();
292+
293+ $ doctrineOrmServiceProvider = new DoctrineOrmServiceProvider ;
294+ $ doctrineOrmServiceProvider ->register ($ app );
295+
296+ $ alias = 'Foo ' ;
297+ $ namespace = 'Foo\Entities ' ;
298+
299+ $ app ['orm.em.options ' ] = array (
300+ 'mappings ' => array (
301+ array (
302+ 'type ' => 'annotation ' ,
303+ 'namespace ' => $ namespace ,
304+ 'path ' => __DIR__ .'/src/Foo/Entities ' ,
305+ 'alias ' => $ alias
306+ )
307+ ),
308+ );
309+
310+ $ this ->assertEquals ($ namespace , $ app ['orm.em.config ' ]->getEntityNameSpace ($ alias ));
311+ }
285312}
You can’t perform that action at this time.
0 commit comments