I have an Intervention entity, another of Failure and another of Prevista and I wanted to go buck the data of these entities and put everything together in a table.
The table that puts everything together will be within the entity Intervention within a details.html file.
Table will be: Intervention: Date, Time and Duration; Fault: Date, Description and Disability; Prevista: COntagem, Duration, Make, Time and Token;
Mytablelookslikethis: factoryworker Intervention Breakdown Preview Id Identity Date Hour Duration Date description Impediment Score Duration Do Time Record {%forentityinentities%} {%ifentity.data%}{{entity.data|date('Y-m-d')}}{%endif%} {%ifentity.horainicio%}{{entity.horainicio|date('H:i')}}{%endif%} {{entity.duration}} {%endfor%}
HowcanIgetthedatafromtheotherentitiesforthistable?
Therelationshipsbetweenthemare:IntheIntervention:
/***@ORM\ManyToOne(targetEntity="RoqSys\Control\ManutencaoBundle\Entity\Maquina", inversedBy="intervencao")
* @ORM\JoinColumn(name="maquina_id", referencedColumnName="id", nullable=false)
*/
private $maquina;
On Failure:
/**
* @ORM\ManyToOne(targetEntity="RoqSys\Control\ManutencaoBundle\Entity\Maquina", inversedBy="avaria")
* @ORM\JoinColumn(name="maquina_id", referencedColumnName="id")
*/
private $maquina;
Prediction:
/**
* @ORM\ManyToOne(targetEntity="RoqSys\Control\ManutencaoBundle\Entity\Maquina", inversedBy="prevista")
* @ORM\JoinColumn(name="maquina_id", referencedColumnName="id")
*/
private $maquina;
No InterventionController:
/**
* Lists all Intervencao entities.
*
* @Route("/", name="manutencao_intervencao")
* @Method("GET")
* @Template()
*/
public function indexAction() {
$em = $this->getDoctrine()->getManager();
$entities =$em->getRepository('RoqSysControlManutencaoBundle:Intervencao')->findAll();
$avarias = $em->getRepository('RoqSysControlManutencaoBundle:Avaria')->findAll();
$previstas = $em->getRepository('RoqSysControlManutencaoBundle:Prevista')->findAll();
return array(
'entities' => $entities,
'avarias' => $avarias,
'previstas' => $previstas,
);
}