Hi, I'm a beginner and I want to get the value found in the following object specifically in: [id:AppBundle\Entity\BlogPost:private] => 1
and store it in a variable.
The first part is the result of print_r
and the second part is the code, thanks
AppBundle\Entity\BlogPost Object
(
[id:AppBundle\Entity\BlogPost:private] => 1
[title:AppBundle\Entity\BlogPost:private] => Primera entrada de Blog
[content:AppBundle\Entity\BlogPost:private] => Lorem Ipsum
[createdAt:AppBundle\Entity\BlogPost:private] => DateTime Object
(
[date] => 2011-01-01 00:00:00.000000
[timezone_type] => 3
[timezone] => Europe/Berlin
)
)
public function showAction($id)
{
$blogentry = $this->getDoctrine()
->getRepository('AppBundle:BlogPost')
->find($id);
echo "<pre>";
print_r($blogentry);
echo "</pre>";
if (!$blogentry) {
throw $this->createNotFoundException(
'No product found for id '. $blogentry
);
}
return $this->render('AppBundle:default:show.html.twig', array(
'blogentry' => $blogentry
));
}