public function setEntityById($id) { $entity = $this->em->getRepository('FRDCarBundle:Carro')->find($id); if (!$entity) { throw $this->container->createNotFoundException("Registro não encontrado"); } $this->carro = $entity; }