P
P
Peter2013-12-18 11:50:48
PHP
Peter, 2013-12-18 11:50:48

Silex - getter for getting user login

Hello.
I continue to understand Silex. This time the following question arose:
Authorization is implemented on the site. And sometimes you want to write the user's login to the database.
The doc contains the code:

$token = $app['security']->getToken();
if (null !== $token) {
    $user = $token->getUser();
}

In this case, an object with private properties is returned. As far as I understand, it is necessary to make a getter to be able to operate with this data.
Please explain how to do this? I don't understand and can't find any info.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
Y
Yuri, 2013-12-18
@error500

Apparently, in the screwed user model, you need to write these getters.

public function getUsername()
{
    return $this->username;
 }
, something like that.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question