Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 4267350
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T06:53:15+00:00 2026-05-21T06:53:15+00:00

I am developing a filter in Symfony to keep track of certain request that

  • 0

I am developing a filter in Symfony to keep track of certain request that users perform within the application. In order to retrieve the current user I use the getContext() method:

$user = $this->getContext()->getUser();

And then I try to access its properties:

...
$username = $user->getUsername();
...

The problem is that Symfony raises the following exception: Call to a member function getUsername() on a non-object in … sfGuardSecurityUser.class.php, unless I retrieve the user this way:

$user = $this->getContext()->getUser()->getGuardUser();

According to sfDoctrineGuardUser documentation (and source code) there are proxy methods like this:

public function getUsername()
{
    return $this->getGuardUser()->getUsername();
}

Why the proxy method is not working?

UPDATE

After a couple of weeks developing, the problem arose again. This time from a view using the $sf_user variable. I can get the ID with

$sf_user->getGuardUser()->getId()

but not with

$sf_user->getId()

In my own answer below is the explanation.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-21T06:53:16+00:00Added an answer on May 21, 2026 at 6:53 am

    Thanks to @Matt Gibson comment I reviewed the installation process of sfDoctrineGuardPlugin. It seems I made a typo somewhere because now everything works well, both

    $this->getGuardUser()->getUsername()
    

    and

    $this->getUsername()
    

    However, I think these proxy methods could be improved because it lacks of a getId method. You can retrieve almost everything except ID, which must be retrieved using the long form:

    $this->getGuardUser()->getId()
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

When developing an application that sends out notification email messages, what are the best
Currently developing an application using the newest version of symfony, obtained through PEAR. This
How do I filter out the Silverlight documentation when I'm developing WPF application in
I'm developing an rss feed reader that uses a bayesian filter to filter out
I'm currently developing a website, into which I've included a filter that attempts to
I am developing a grails application.In that some cases I want to control the
Developing a web application that I've registered with Twitter. In this app, I might
I am currently developing an application that uses databases dynamically. meaning it is designed
I am developing an application that runs completely unattended and displays some info on
I am currently developing a GWT 2.1 application that is to be deployed on

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.