Created
October 29, 2011 07:34
-
-
Save codecowboy/1324206 to your computer and use it in GitHub Desktop.
DefaultController
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public function indexAction() | |
{ | |
$user = $user = $this->get('security.context')->getToken()->getUser(); | |
$challenge = $this->getDoctrine() | |
->getRepository('GymloopCoreBundle:Challenge') | |
->find(1); | |
if(!$challenge) { | |
throw $this->createNotFoundException('No challenge found'); | |
} | |
$coordinates = $challenge->getCoordinates(); | |
//get the UserChallenge object for this challenge id (if it exists) | |
//pass the user's distance to the view | |
$UserChallenge = $this->getDoctrine() | |
->getRepository('GymloopCoreBundle:UsersChallenges') | |
->findOneByUserAndChallenge($user,$challenge); | |
if($UserChallenge) { | |
\Doctrine\Common\Util\Debug::dump($UserChallenge); | |
$userDistance = $UserChallenge->getDistance(); | |
} else { | |
$userDistance = 0; | |
} | |
return $this->render('GymloopChallengeBundle:Default:index.html.twig', array('challenge' => $challenge, 'user_distance'=> $userDistance)); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment