This question already has an answer here:
I'm trying to access the properties of my SheriffUser instance to store them in separate variables and manipulate them ($email, $password, $fullname...) I tried to do a get_object_vars but it returns nothing.
An instantiation doesn't work either because there are missing properties.
namespace Aecf\DemoBundle\AuthTest;
use Symfony\Component\Security\Core\Event\AuthenticationEvent;
use Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface;
use Aecf\SecurityBundle\Security\Core\User;
class AuthTestPrint
{
public function printSomething(AuthenticationEvent $event){
dump('Authentication detected');
$token = $event->getAuthenticationToken();
$user=$token->getUser();
dump($user);
var_dump($user);
//$user = new User\SheriffUser($token->getUser());
}
}
Here is the result of dump(user)
;
AuthTestPrint.php on line 17:
SheriffUser {#443 ▼
-email: "user"
-actions: array:1 [▶]
-password: "user"
-fullName: "user"
-accessToken: "iAnytnwIwEJSUzI1NiJ9.UBhnIBsOlgFtZSI6IlVzZXIiLCJ1c2VybmFtZSI6InVzZXIiLCJleHAiOjMzMDQyMTY0MDcxLCJpYXQiOjE0ODUyNTUyNzF9.LQU1NV8FMZGH9b3r7Rn4BrPK5Qany6ym_EyA9MMteI ▶"
-shops: ArrayCollection {#444 ▶}
-locale: null
-refreshToken: null
-expiresAt: null
}
The result of var_dump($user);
object(Aecf\SecurityBundle\Security\Core\User\SheriffUser)#443 (9) { ["email":"Aecf\SecurityBundle\Security\Core\User\SheriffUser":private]=> string(4) "user" ["actions":"Aecf\SecurityBundle\Security\Core\User\SheriffUser":private]=> array(1) { [0]=> array(2) { ["type"]=> string(7) "generic" ["name"]=> string(9) "ROLE_USER" } } ["password":"Aecf\SecurityBundle\Security\Core\User\SheriffUser":private]=> string(4) "user" ["fullName":"Aecf\SecurityBundle\Security\Core\User\SheriffUser":private]=> string(4) "user" ["accessToken":"Aecf\SecurityBundle\Security\Core\User\SheriffUser":private]=> string(801) "iAnytnwIwEJSUzI1NiJ9.UBhnIBsOlgFtZSI6IlVzZXIiLCJ1c2VybmFtZSI6nVzZXIiLCJleHAiOjMzMDQyMTY0MDcxLCJpYXQiOjEODUyNTUyNzF9.LQU1NV8FMZGH9b3r7Rn4BrPK5Qany6ym_EyA9MMteImlDrjAs45vIvr0BLKsU4N7isvGGRDc_MXphWUm6p61LMVTcFOGmlERd1B2BEmWkkDVTKEy5jBu7vOVHqK5LYLseAB4K3Qxk17cDe80uO1vutbeb0syWykuspHuWunr_tTqoot70jYCEmbhv_4jsxnxowpsoL13iIkkqGdtdLjxTQ5RQE5sjhXnguiHDeC4Fhm1-gsptQmCp00yzdq9GcPFurddtP_MWNjX4NwqhuZjiIVeQqG154ocbF_Z49a6aj2tLsNY_vpinaCcwvNL5Yshg1n964JrQZM4U0ysrWE1oPI887rhHBilwrtk1l1Z5czUH8zVLMzeAzSMr0MvidjM01nKidbbVJBXmaACoyqcftFNAG7_CZijW2oYlZe7UiJ71cpvrxzOr1Tlpgs4YmvxRC4bIwijdI_QJXwDmL4Q-JfRfAu4g9JigEoCHLV-oU56D_e2Btd3X4uL7EII-F--0LKcuFb1_eK8GTvcECz7rRAPhpv0Hi4kxJfIQtKFvOnJ3W0JA0X5d_-x2Jn__TdArZIVYWChnWKFw2tv7UuQ9ymGoUiq7qH0OSPmF7DMQtudFE7bszyaK1X_wVhHSFej82HVqL_SVC4epEle5_53xrJCIuTIgl0sE" ["shops":"Aecf\SecurityBundle\Security\Core\User\SheriffUser":private]=> object(Doctrine\Common\Collections\ArrayCollection)#444 (1) { ["elements":"Doctrine\Common\Collections\ArrayCollection":private]=> array(0) { } } ["locale":"Aecf\SecurityBundle\Security\Core\User\SheriffUser":private]=> NULL ["refreshToken":"Aecf\SecurityBundle\Security\Core\User\SheriffUser":private]=> NULL ["expiresAt":"Aecf\SecurityBundle\Security\Core\User\SheriffUser":private]=> NULL }
</div>