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;
 }