In the latest version of Symfony 2 (using FOSUserBundle and SonataUserBundle), I am trying to get the current user to pre-populate the form in my new Entity controller.
In mycontroller.yml :
my_controller_new: pattern: /new defaults: { _controller: "MySiteBundle:MyController:new" }
In MyController.php :
public function newAction() { $user = $this->getUser();
But when I call $this->getUser() , the method returns null . Despite the fact that I logged in (I can access /profile and update user information without any problems)
Then I tried to check if the session was started:
public function newAction() { var_dump($this->get('session')->isStarted());
It returns false. What is wrong here?
source share