Hello, I have the following code:
Old code:
public function historicoAction() {
$entity = new Intervencao();
$em = $this->getDoctrine()->getManager();
$entities = $em->getRepository('RoqSysControlManutencaoBundle:Intervencao')->findAll();
$maquinas = $em->getRepository('RoqSysControlManutencaoBundle:Maquina')->findAll();
$prevista = $em->getRepository('RoqSysControlManutencaoBundle:Prevista')->findAll();
$entity->setDescricao($prevista->getDescricao());
return array(
'entity' => $entity,
'entities' => $entities,
'maquinas' => $maquinas,
);
}
It gives me the following error:
Error: Call to a member function getDescription () on a non-object in /var/www/roqsys/src/RoqSys/Control/ManutencaoBundle/Controller/IntervencaoController.php line 76
Edit **
New code:
I've tried the following:
public function historicoAction() {
$entity = new Intervencao();
$em = $this->getDoctrine()->getManager();
$entities = $em->getRepository('RoqSysControlManutencaoBundle:Intervencao')->findAll();
$maquinas = $em->getRepository('RoqSysControlManutencaoBundle:Maquina')->findAll();
$prevista = $em->getRepository('RoqSysControlManutencaoBundle:Prevista')->findAll();
var_dump($prevista);
foreach($prevista as $obj) {
echo $prevista->getDescricao();
}
$entity->setDescricao($prevista->getDescricao());
return array(
'entity' => $entity,
'entities' => $entities,
'prevista' => $prevista,
'maquinas' => $maquinas,
);
}
And yet it gives me the same error.