示例#1
0
 private function setActivity($routeNum, $activityDate, $activityName, $wikilocId = null, $activityDistance, $activityGain)
 {
     /** @var Activity The Activiti entity to add */
     $activity = $this->manager->getRepository('OesteveGrupetaBundle:Activity')->findOneBy(array('name' => $activityName));
     if (!$activity) {
         $activity = new Activity();
     }
     $activity->setName($activityName);
     $activity->setSlug(Slug::slugify($activityName));
     $activity->setDescription("Ruta PBM #" . $routeNum . " por: " . $activityName);
     $activity->setDatetime($activityDate);
     $activity->setWikilocId($wikilocId);
     $activity->setDistance($activityDistance);
     $activity->setElevationGain($activityGain);
     $activity->setClub($this->pbmClub);
     return $activity;
 }
 /**
  * Proces new or updated activities
  * 
  * @param Activity $activity
  */
 private function processForm(Activity $activity)
 {
     if ($activity->getSlug() == null) {
         $em = $this->getDoctrine()->getManager();
         $i = 1;
         $slug = Slug::slugify($activity->getName());
         $exists = $em->getRepository("OesteveGrupetaBundle:Activity")->findOneBy(array('slug' => $slug));
         while ($exists != null) {
             $slug = Slug::slugify($activity->getName() . '-' . $i++);
             $exists = $em->getRepository("OesteveGrupetaBundle:Activity")->findOneBy(array('slug' => $slug));
         }
         $activity->setSlug($slug);
     }
     return $activity;
 }