Example #1
0
 /**
  * Proces club before form handleRequest
  * 
  * @param Club $club
  */
 private function processForm(Athlete $athlete)
 {
     if ($athlete->getSlug() == null) {
         $em = $this->getDoctrine()->getManager();
         $i = 1;
         $slug = Slug::slugify($athlete->getTitle());
         $exists = $em->getRepository("OesteveGrupetaBundle:Athlete")->findOneBy(array('slug' => $slug));
         while ($exists != null) {
             $slug = Slug::slugify($athlete->getTitle() . '-' . $i++);
             $exists = $em->getRepository("OesteveGrupetaBundle:Athlete")->findOneBy(array('slug' => $slug));
         }
         $athlete->setSlug($slug);
     }
     if ($athlete->getImageFile() != null) {
         $image = new Image();
         $image->setFile($athlete->getImageFile());
         $image->setName($athlete->getImageFile()->getClientOriginalName());
         $athlete->setImage($image);
     }
     if ($athlete->getCoverImageFile() != null) {
         $image = new Image();
         $image->setFile($athlete->getCoverImageFile());
         $image->setName($athlete->getCoverImageFile()->getClientOriginalName());
         $athlete->setCoverImage($image);
     }
     return $athlete;
 }
 /**
  * Creates a form to delete a Post entity by id.
  *
  * @param mixed $id The entity id
  *
  * @return \Symfony\Component\Form\Form The form
  */
 private function createDeleteForm(Athlete $athlete, Post $post)
 {
     return $this->createFormBuilder()->setAction($this->generateUrl('athlete_post_delete', array('slug' => $athlete->getSlug(), 'post_slug' => $post->getSlug())))->setMethod('DELETE')->add('submit', 'submit', array('label' => 'Eliminar', 'attr' => array('data-type' => 'submit_delete')))->getForm();
 }