xxxxxxxxxx
$user = $this->get('security.token_storage')->getToken()->getUser();
$user->getUsername();
xxxxxxxxxx
$user = $this->get('security.token_storage')->getToken()->getUser();
$user->getUsername();
xxxxxxxxxx
class SomeService
{
/** @required */
private TokenStorageInterface $tokenStorage;
protected function getUser(): UserInterface
{
return $this->tokenStorage->getToken()->getUser();
}
}