Yep. That is the Deal as Chris said. What provider are you using?? Providers are set in app/config/security.yml
something like: security: encoders: #you should have something here as well. providers: main: entity: { class: Company\SomeBundle\Entity\Customer, property: username } So if you have this, the security context will bind the security user with your Customer entity. That entity would have: name; lastname; id; And of course its getters and setters. You should read the official docs. Also you can check this tutorial, is very good, though it is a little out to date but it may help you a lot. http://www.dobervich.com/2011/03/21/symfony2-blog-application-tutorial-part-v-intro-to-security/ 2011/5/8 Christophe COEVOET <s...@notk.org> > Le 07/05/2011 11:54, [BLZ]梁振警 a écrit : > > My database schema is something like this: >> >> create table users ( >> id INT PRIMARY KEY, >> username TEXT, >> ) >> >> create table posts ( >> id INT PRIMARY KEY, >> user_id INT, >> title TEXT, >> content TEXT, >> ) >> >> Now, I want to get all posts of current logged in user, but I can't >> get find a way to get current userid, like this: >> >> $user = $this->container->get('security.context')->getToken()->getUser(); >> $repo->findBy(array('user_id' => $user->getId())) >> >> But I got " Fatal Error: Call to undefined method", I wonder if there >> any way to get UserId? >> >> I look through Symfony\Component\Security\Core\User\UserInterface, >> Symfony\Component\Security\Core\User\AdvancedUserInterface, non of >> them providered getId() method. >> >> Any one can help me? Thanks. >> > Which user provider are you using ? > > -- > Christophe | Stof > > > -- > If you want to report a vulnerability issue on symfony, please send it to > security at symfony-project.com > > You received this message because you are subscribed to the Google > Groups "symfony users" group. > To post to this group, send email to symfony-users@googlegroups.com > To unsubscribe from this group, send email to > symfony-users+unsubscr...@googlegroups.com > For more options, visit this group at > http://groups.google.com/group/symfony-users?hl=en > -- If you want to report a vulnerability issue on symfony, please send it to security at symfony-project.com You received this message because you are subscribed to the Google Groups "symfony users" group. To post to this group, send email to symfony-users@googlegroups.com To unsubscribe from this group, send email to symfony-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/symfony-users?hl=en