I have the authentification controller
public function indexAction(Request $request)
{
$em = $this->getDoctrine()->getEntityManager();
$repository = $em->getRepository('Mql14mqlmeBundle:User');
if ('POST' === $request->getMethod()) {
$username = $request->get('login');
$password = $request->get('pass');
if(($username=='admin')&&($password=='admin')){
return $this->redirect($this->generateUrl('mql14mqlme_admin', array('name' => 'welcome')));
}
$user = $repository->findOneBy(array('login' => $username, 'pass' => $password));
if ($user) {
return $this->redirect($this->generateUrl('mql14mqlme_acceuil', array('name' => $user->getNom(),
'id'=> $user->getId(),
)));
}else {
return $this->redirect($this->generateUrl('mql14mqlme_homepage', array('name' =>$username)));
}
If the user has provided the right login and password he is redirected to acceuil twig, in this twig I want to get the user's id to use it in another twig, so the line where I have a problem is this:
<a href="{{ path('mql14mqlme_interet', { 'id': name }) }}">INTERETS</a>
the error I get is:Variable "name" does not exist in Mql14mqlmeBundle:Default:acceuil.html.twig at line 89
The action code for acceuil:
public function acceuilAction()
{
$em = $this->container->get('doctrine')->getEntityManager();
$evenements= $em->getRepository('Mql14mqlmeBundle:Evenement')->findAll();
$categories= $em->getRepository('Mql14mqlmeBundle:Categorie')->findAll();
return $this->container->get('templating')->renderResponse('Mql14mqlmeBundle:Default:acceuil.html.twig',
array(
'evenements' => $evenements,
'categories' => $categories
));
}