I have to ask how to get name of logged user into Nette component (SomethingControl.php). Apparently I can't just do this:
$identity = $this->getUser()->getIdentity();
if ($identity) $this->template->username = $identity->getData()['username'];
So I've tried this:
$this->template->username = $this->user
but that doesn't work either.
You cannot get user like this, because
UI\Controlis not descendant of UI\Presenter. ButNette\Security\Useris service registered in DIC so you can get it like this:Just make sure that you are using Component Factory - means do not create your component in the presenter using
newoperator.