I am using the Symfony security setup. Everything works fine, but I don't know how to do one important thing:
In twig, I can reach the current user's info by doing:
Welcome, {{ app.user.username }}
or similar
How do I access this same information in the Controller? Specifically, I want to get the current user entity so I can store it relationally in another entity (one-to-one mapping).
I was really hoping it'd be
$this->get('security.context')->getToken()->getUser()
but that doesn't work. It gives me a class of type
Symfony\Component\Security\Core\User\User
and I want one of type
Acme\AuctionBundle\Entity\User
which is my entity....