@@ -171,7 +171,7 @@ private function generateDocumentConstructor(array $metadata)
171171
172172 foreach ($ metadata ['properties ' ] as $ prop ) {
173173 if ($ prop ['annotation ' ] == 'embedded ' && isset ($ prop ['property_multiple ' ]) && $ prop ['property_multiple ' ]) {
174- $ fields [] = sprintf ('%s$this->%s = new Collection (); ' , $ this ->spaces , $ prop ['field_name ' ]);
174+ $ fields [] = sprintf ('%s$this->%s = new ArrayCollection (); ' , $ this ->spaces , $ prop ['field_name ' ]);
175175 }
176176 }
177177
@@ -239,7 +239,8 @@ private function generatePropertyDocBlock(array $metadata)
239239 $ column [] = 'options={ ' . $ metadata ['property_options ' ] . '} ' ;
240240 }
241241
242- $ lines [] = $ this ->spaces . ' * @ES \\' . ucfirst ($ metadata ['annotation ' ]) . '( ' . implode (', ' , $ column ) . ') ' ;
242+ $ lines [] = $ this ->spaces . ' * @ES \\' . Inflector::classify ($ metadata ['annotation ' ])
243+ . '( ' . implode (', ' , $ column ) . ') ' ;
243244
244245 $ lines [] = $ this ->spaces . ' */ ' ;
245246
@@ -259,9 +260,8 @@ private function generateDocumentDocBlock(array $metadata)
259260 ['<className> ' , '<annotation> ' , '<options> ' ],
260261 [
261262 $ this ->getClassName ($ metadata ),
262- ucfirst ($ metadata ['annotation ' ]),
263- $ metadata ['annotation ' ] != 'object ' ? ($ metadata ['type ' ] != lcfirst ($ this ->getClassName ($ metadata ))
264- ? sprintf ('type="%s" ' , $ metadata ['type ' ]) : '' ) : '' ,
263+ Inflector::classify ($ metadata ['annotation ' ]),
264+ $ this ->getAnnotationOptions ($ metadata ),
265265 ],
266266 '/**
267267 * <className>
@@ -302,6 +302,26 @@ private function getClassName(array $metadata)
302302 ? substr ($ metadata ['name ' ], $ pos + 1 , strlen ($ metadata ['name ' ])) : $ metadata ['name ' ];
303303 }
304304
305+ /**
306+ * Returns annotation options
307+ *
308+ * @param array $metadata
309+ *
310+ * @return string
311+ */
312+ private function getAnnotationOptions (array $ metadata )
313+ {
314+ if (in_array ($ metadata ['annotation ' ], ['object ' , 'object_type ' ])) {
315+ return '' ;
316+ }
317+
318+ if ($ metadata ['type ' ] === Inflector::tableize ($ this ->getClassName ($ metadata ))) {
319+ return '' ;
320+ }
321+
322+ return sprintf ('type="%s" ' , $ metadata ['type ' ]);
323+ }
324+
305325 /**
306326 * Generates document use statements
307327 *
@@ -314,7 +334,7 @@ private function generateDocumentUse(array $metadata)
314334 $ uses = ['use ONGR\ElasticsearchBundle\Annotation as ES; ' ];
315335
316336 if ($ this ->hasMultipleEmbedded ($ metadata )) {
317- $ uses [] = 'use ONGR\ElasticsearchBundle\Collection\Collection ; ' ;
337+ $ uses [] = 'use Doctrine\Common\Collections\ArrayCollection ; ' ;
318338 }
319339
320340 return implode ("\n" , $ uses ) . "\n" ;
0 commit comments