Ver Mensaje Individual
  #3 (permalink)  
Antiguo 23/02/2015, 14:51
Avatar de hhs
hhs
Colaborador
 
Fecha de Ingreso: junio-2013
Ubicación: México
Mensajes: 2.995
Antigüedad: 10 años, 10 meses
Puntos: 379
Respuesta: Enviar entidad a la vista con JSON en Symfony 2

Desde symfony 2.1 puede usar el objeto JsonResponse
Código PHP:
Ver original
  1. use Symfony\Component\HttpFoundation\JsonResponse; //agregar
  2.  
  3. $areas=$em->getRepository('AuditoriaBundle:Area')->findAll();
  4.  
  5. $response = new JsonResponse();
  6. $response->setData(array(
  7.  'data' => $areas
  8. ));
__________________
Saludos
About me
Laraveles
A class should have only one reason to change.