Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>You're not doing anything wrong as that's how symfony generates them. I usually don't use the app/console to generate them as currently they're not doing a good job. One example is as you've mentioned the pluralization of words as you've mentioned. Another obvious one is the fact that it's using the <code>[]</code> notation which is pretty much treating an <code>ArrayCollection</code> object as a PHP array. You <strong>should never</strong> treat ArrayCollections as arrays.</p> <p>This is how I have implemented it myself:</p> <pre><code>public function addCategory(Category $category) { if (!$this-&gt;categories-&gt;contains($category) $this-&gt;categories-&gt;add($category); return $this; } </code></pre> <p>Which doesn't add duplicates to the Array collection if it's already added. Same thing goes with remove:</p> <pre><code>public function removeCategory(Category $category) { if ($this-&gt;categories-&gt;contains($category) $this-&gt;categories-&gt;remove($category); } </code></pre> <p>What I've run into many times is let's say you have 4 categories and you add and remove them</p> <pre><code>$r = new Recipe(); $c1 = new Category(); $c2 = new Category(); $r-&gt;addCategory($c1); $r-&gt;addCategory($c2); // at this point $r-&gt;getCategories()-&gt;toArray()[0] contains $c1 // and $r-&gt;getCategories()-&gt;toArray()[1] contains $c2 $r-&gt;removeCategory($c1); // now $r-&gt;getCategories()-&gt;toArray()[0] is empty and // $r-&gt;getCategories()-&gt;toArray()[1] contains $c2 still // so in order to get the first category you need to: $r-&gt;getCategories()-&gt;first(); </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload