public function supprPhotoAction(Photo $id)
 {
     $update = FALSE;
     if ($id->getUser()) {
         // photo reliée à un user
         $dest = 'User';
         $user = $id->getUser();
         // On teste pour savoir s'il s'agit d'une photo principale
         if ($id->getPrincipal() === TRUE) {
             $update = TRUE;
         }
     } else {
         // photo reliée à un objet
         $dest = 'Obj';
         $objet = $id->getObjet();
         // On stocke l'id de l'objet pour redircetion.
         $ret = $id->getObjet()->getId();
         if ($id->getPrincipal() === TRUE) {
             $update = TRUE;
         }
     }
     $em = $this->getDoctrine()->getManager();
     $em->remove($id);
     $em->flush();
     // si on supprime une photo principale, on en rend une autre principale
     if ($update === TRUE) {
         if ($dest === 'User') {
             $photo = $em->getRepository("fsmEchangeBundle:Photo")->findOneByUser($user);
             // il se peut qu'il n'y ait plus de photos
             if ($photo) {
                 $photo->setPrincipal(TRUE);
             }
         } else {
             $photo = $em->getRepository("fsmEchangeBundle:Photo")->findOneByObjet($objet);
             if ($photo) {
                 $photo->setPrincipal(TRUE);
             }
         }
     }
     // On supprime la photo passée en input
     $em->flush();
     $this->get('session')->getFlashBag()->add('info', 'la photo a bien été supprimée');
     if ($dest === 'User') {
         return $this->redirect($this->generateUrl('fos_user_profile_edit'));
     } else {
         return $this->redirect($this->generateUrl('fsm_photo_ajout_O', array('id' => $ret)));
     }
 }
 /**
  * {@inheritDoc}
  */
 public function getAlt()
 {
     $this->__initializer__ && $this->__initializer__->__invoke($this, 'getAlt', array());
     return parent::getAlt();
 }