I use the symfony 3 and try to get the current user data in Entity Repository file, but when i used
$this->get('security.token_storage')->getToken()->getUser();, there is a error message that is can not found the
get function So, how to do it? PS: if in the form type, how to invoke the user data. Thanks.
Entity Repository has not Container. You can find solution how do it (as example here Symfony2: How to access to service from repository), but it is not best practice. Repositories have only one goal - work with data from the database. You can pass the user object as parameter for your method.