title: How to remove galleryhasmedia from gallery sonatamediabundle
body: <p>I am trying to remove galleryhasmedia from gallery.</p>
  
  <p>However gallery entity doesn't have removegalleryhasmedia or something.</p>
  
  <p>so I did a clumsy way, but it doesnt work.</p>
  
  <pre><code>$em = $this-&gt;getDoctrine()-&gt;getManager();
  
  $firstGhmArray = $gallery-&gt;getGalleryHasMedias();
  echo count($gallery-&gt;getGalleryHasMedias()) // before count
  $afterGhmArray = array();
  foreach ($firstGhmArray as $ghm){
  
          if ($ghm-&gt;getId() == $id){ // id is the target id to delete
                  //delete    
          }
          else {
              array_push($afterGhmArray , $ghm);
          }
          $gallery-&gt;setGalleryHasMedias($afterGhmArray);
      }
  echo count($gallery-&gt;getGalleryHasMedias()) // after count
  $em-&gt;persist($gallery);
  $em-&gt;flush();
  </code></pre>
  
  <p>I think if galleryHasMedias are normal array collection.</p>
  
  <p>I can delete the element with this procedure.</p>
  
  <p>I need to do something more for galleryhasmedia??</p>