Answer the question
In order to leave comments, you need to log in
Why doesn't Twig see the variable?
Understanding FOSRestBundle in Symfony 3.
Made a controller:
<?php
namespace AppBundle\Controller;
use FOS\RestBundle\Controller\FOSRestController;
class UsersController extends FOSRestController
{
public function getUsersAction()
{
$data = ['name'=>'John']; // get data, in this case list of users.
$view = $this->view($data, 200)
->setTemplateData(['role'=>'user'])
->setTemplate("AppBundle:UsersController:get_users.html.twig")
->setTemplateVar('users');
return $this->handleView($view);
}
}
home:
path: /
defaults: { _controller: AppBundle:Default:index }
test:
path: /test
defaults: { _controller: AppBundle:Users:getUsers }
test_api:
path: /api/test
defaults: { _controller: AppBundle:Users:getUsers }
Answer the question
In order to leave comments, you need to log in
The problem lies in the fosrestbundle with it and needs to be dealt with: stackoverflow.com/questions/12457683/fosrestbundle...
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question