@@ -187,7 +187,7 @@ private function generateDocumentConstructor(array $metadata)
187187
188188 foreach ($ metadata ['properties ' ] as $ prop ) {
189189 if ($ prop ['annotation ' ] == 'embedded ' && isset ($ prop ['property_multiple ' ]) && $ prop ['property_multiple ' ]) {
190- $ fields [] = sprintf ('%s$this->%s = new Collection (); ' , $ this ->spaces , $ prop ['field_name ' ]);
190+ $ fields [] = sprintf ('%s$this->%s = new ArrayCollection (); ' , $ this ->spaces , $ prop ['field_name ' ]);
191191 }
192192 }
193193
@@ -255,7 +255,8 @@ private function generatePropertyDocBlock(array $metadata)
255255 $ column [] = 'options={ ' . $ metadata ['property_options ' ] . '} ' ;
256256 }
257257
258- $ lines [] = $ this ->spaces . ' * @ES \\' . ucfirst ($ metadata ['annotation ' ]) . '( ' . implode (', ' , $ column ) . ') ' ;
258+ $ lines [] = $ this ->spaces . ' * @ES \\' . Inflector::classify ($ metadata ['annotation ' ])
259+ . '( ' . implode (', ' , $ column ) . ') ' ;
259260
260261 $ lines [] = $ this ->spaces . ' */ ' ;
261262
@@ -275,9 +276,8 @@ private function generateDocumentDocBlock(array $metadata)
275276 ['<className> ' , '<annotation> ' , '<options> ' ],
276277 [
277278 $ this ->getClassName ($ metadata ),
278- ucfirst ($ metadata ['annotation ' ]),
279- $ metadata ['annotation ' ] != 'object ' ? ($ metadata ['type ' ] != lcfirst ($ this ->getClassName ($ metadata ))
280- ? sprintf ('type="%s" ' , $ metadata ['type ' ]) : '' ) : '' ,
279+ Inflector::classify ($ metadata ['annotation ' ]),
280+ $ this ->getAnnotationOptions ($ metadata ),
281281 ],
282282 '/**
283283 * <className>
@@ -318,6 +318,26 @@ private function getClassName(array $metadata)
318318 ? substr ($ metadata ['name ' ], $ pos + 1 , strlen ($ metadata ['name ' ])) : $ metadata ['name ' ];
319319 }
320320
321+ /**
322+ * Returns annotation options
323+ *
324+ * @param array $metadata
325+ *
326+ * @return string
327+ */
328+ private function getAnnotationOptions (array $ metadata )
329+ {
330+ if (in_array ($ metadata ['annotation ' ], ['object ' , 'object_type ' ])) {
331+ return '' ;
332+ }
333+
334+ if ($ metadata ['type ' ] === Inflector::tableize ($ this ->getClassName ($ metadata ))) {
335+ return '' ;
336+ }
337+
338+ return sprintf ('type="%s" ' , $ metadata ['type ' ]);
339+ }
340+
321341 /**
322342 * Generates document use statements
323343 *
@@ -330,7 +350,7 @@ private function generateDocumentUse(array $metadata)
330350 $ uses = ['use ONGR\ElasticsearchBundle\Annotation as ES; ' ];
331351
332352 if ($ this ->hasMultipleEmbedded ($ metadata )) {
333- $ uses [] = 'use ONGR\ElasticsearchBundle\Collection\Collection ; ' ;
353+ $ uses [] = 'use Doctrine\Common\Collections\ArrayCollection ; ' ;
334354 }
335355
336356 return implode ("\n" , $ uses ) . "\n" ;
0 commit comments