Lea*_*lli 0 json controller symfony twig
我在渲染 Twig 视图和 JSON 响应时遇到问题,我需要调用 twig 视图并将一个新的 Json 响应作为参数传递给它。输出错误如下“Notice: Object of class Symfony\Component\HttpFoundation\Response could not be convert to int” 这里是代码
$resultado = array('mes1_local' => $mes1_local, 'mes2_local' => $mes2_local, 'mes3_local' => $mes3_local, 'mes1_online' => $mes1_online, 'mes2_online' => $mes2_online, 'mes3_online' => $mes3_online, 'contador_pedido_local' => $contador_pedido_local, 'contador_pedido_online' => $contador_pedido_online, 'contador_total' => $contador_total, 'contador_usuarios' => $contador_usuarios);
return new JsonResponse($resultado, $this->render('others/adminlte.html.twig'));
Run Code Online (Sandbox Code Playgroud)
就像@goto 的答案一样,但它不起作用,因为您需要使用renderView而不是render:
return new JsonResponse([
'things' => $thingsArray,
'anotherVariable' => $simpleVariable,
'html' => $this->renderView('others/adminlte.html.twig', []/* template parameters goes here */),
]);
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
3282 次 |
| 最近记录: |