Hello i have a problem i would like to retrieve data from my entity in Symfony here is the code:
public function indexAction(Request $request , $id)
{
$getDoctrine = $this->getDoctrine()->getManager();
$email = $getDoctrine->getRepository('desplayBundle:people')->find($id);
dump($email);
return $this->render('emailBundle:Default:index.html.twig', array());
}
I would like to retrieve the data inside my controller and not in twig.
You want to get email from user ?
public function indexAction(Request $request , $id)
{
$getDoctrine = $this->getDoctrine()->getManager();
$user = $getDoctrine->getRepository('desplayBundle:people')->find($id);
$email = $user->getEmail();
return $this->render('emailBundle:Default:index.html.twig', array());
}
You need to ensure that in your entity you've getter of your data and then add this line of code instead of your dump.
public function indexAction(Request $request , $id)
{
$getDoctrine = $this->getDoctrine()->getManager();
$email = $getDoctrine->getRepository('desplayBundle:people')->find($id);
$data = $email->getData();
return $this->render('emailBundle:Default:index.html.twig', array());
}