title: Symfony/ VichUploaderBundle: Remove Entity
body: <p>I'm using the VichUploader to manage File Uploads in my Symfony 3 Application. Now I wonder how to manage deleting Files/ Entities?</p>
  
  <p>Excerpt of the app/config/config.yml:</p>
  
  <pre><code>vich_uploader:
      db_driver: orm
      mappings:
          upload_artists:
              uri_prefix:         /upload/artists
              upload_destination: %kernel.root_dir%/../web/upload/artists
              directory_namer:    artist_directory_namer
              namer:              vich_uploader.namer_uniqid
              inject_on_load:     false
              delete_on_update:   true
              delete_on_remove:   true
  </code></pre>
  
  <p>Excerpt of the Entity:</p>
  
  <pre><code>use Doctrine\ORM\Mapping as ORM;
  use Symfony\Component\Validator\Constraints as Assert;
  use Symfony\Component\HttpFoundation\File\File;
  use Vich\UploaderBundle\Mapping\Annotation as Vich;
  
  /**
   * @ORM\Entity
   * @ORM\Table(name="image_file")
   * @Vich\Uploadable 
   */
  class ImageFile {
  
      /**
       * @ORM\Id
       * @ORM\Column(type="integer")
       * @ORM\GeneratedValue(strategy="AUTO")
       */
      private $id;
  
      /**
       * @ORM\Column(type="string", length=255, nullable=true)
       *
       */
      private $title;
  
      /**
       * NOTE: This is not a mapped field of entity metadata, just a simple property.
       * 
       * @Vich\UploadableField(mapping="upload_artists", fileNameProperty="imageName")
       * 
       * @var File
       */
      private $imageFile;
  
      /**
       * @ORM\Column(type="string", length=255)
       *
       * @var string
       */
      private $imageName;
  
      /**
       * @ORM\Column(type="datetime")
       *
       * @var \DateTime
       */
      private $updatedAt;
  
      /** 
       * @ORM\ManyToOne(targetEntity="Artist") 
       * @ORM\JoinColumn(name="artist_id", referencedColumnName="id") 
       */ 
      private $artist;
  
      /**
       * @ORM\Column(type="boolean")
       */
      private $deleted;
  </code></pre>
  
  <p>Excerpt of the Controller:</p>
  
  <pre><code>namespace Acme\Bundle\Controller;
  
  use Symfony\Bundle\FrameworkBundle\Controller\Controller;
  use Symfony\Component\HttpFoundation\Request;
  use Symfony\Component\HttpFoundation\Response;
  use Acme\Bundle\Entity\Artist;
  use Acme\Bundle\Entity\ImageFile;
  
  class ArtistPhotoController extends Controller {
  
      // ...
  
      public function deleteDisabledAction($id = null) {
          $artist = $this-&gt;getDoctrine()
              -&gt;getRepository('Bundle:Artist')
              -&gt;find($id)
          ;
          $repository = $this-&gt;getDoctrine()-&gt;getRepository('Bundle:ImageFile');
          $photosDisabled = $repository-&gt;findBy(array('artist' =&gt; $artist, 'application' =&gt; $this-&gt;application, 'deleted' =&gt; 1), array('updatedAt' =&gt; 'DESC'));
          $counter = 0;
  
          foreach ($photosDisabled as $disabled) {
              if($disabled-&gt;remove()) {
                  $counter++;
              }
          }
  
          if ($counter &gt; 0) {
              $this-&gt;addFlash(
                  'success',
                  $counter.' items successfully deleted!'
              );
          }
      }
  }
  </code></pre>
  
  <p>... '$disabled->remove()' was just a test and results in an error message ("undefined method named remove").
  How's the correct method to remove/ delete a file/ an entity managed by the VichUploader? Any hints?
  Thanks in advance!</p>