want to send an email from my Symfony2 application, this email must contain a link of confirmation and when the user clicks on this link the state of a field in DB to change.
i have this in my controller:
$message = \Swift_Message::newInstance()
->setSubject('demande de conge ')
->setFrom($col->getEmailCollaborateur())
->setTo($form->get("emailcdp")->getData())
->setBody($this->render('AcmeBundle:Conge:demandeCongeNormal.html.twig', array('conge' => $conge, 'id'=> $this->getUser()->getId())))
;
$this->get('mailer')->send($message);
in the twig :
id de collab: {{ id }}
pour confirmer la demande :
{{ url('confirmer_conge' ,{'username': ' id '}) }}
but in the Email i have this :
http://local.symfony2.com/app_dev.php/confirm/?username=+id+
i want to get the id of user that send the message in another controller for update my DB
in my routing.yml:
confirmer_conge:
pattern: /confirm/{username}
defaults: { _controller: acmeBundle:Conge:confirme }
and in the controller i have this function:
public function confirmeAction()
{return $this->render('acmeBundle:Conge:confirmer.html.twig');
}