File tree Expand file tree Collapse file tree 1 file changed +10
-5
lines changed
Expand file tree Collapse file tree 1 file changed +10
-5
lines changed Original file line number Diff line number Diff line change @@ -209,26 +209,31 @@ class Product
209209 /**
210210 * @var ContentMetaObject
211211 *
212- * @ES\E mbedded(class="App\D ocument\C ategoryObject")
212+ * @ES\E mbedded(class="App\D ocument\C ategoryObject", singular=true )
213213 */
214214 private $category;
215215
216216 //...
217217
218- public function __construct( )
218+ public funtion setCategory($category )
219219 {
220- $this->category = new ArrayCollection() ;
220+ $this->category = $category ;
221221 }
222222
223- public funtion addCategory ($category)
223+ public function getCategory ($category)
224224 {
225- $this->category->add($category)
225+ return $this->category;
226226 }
227227
228228 //...
229229}
230230` ` `
231231
232+ Please note that if you want the category to be embedded as a singular
233+ object (not an array of objects), you need to use the `singular=true` in the
234+ annotation, otherwise it will be interpreted as a collection. Read more on
235+ embedding collections bellow.
236+
232237And the `Category` object will look like (it's a separate class) :
233238
234239` ` ` php
You can’t perform that action at this time.
0 commit comments