auth = $auth; } /** * @return TwigFunction[] */ public function getFunctions() { return [ new TwigFunction('is_user', [$this, 'isAuthenticated']), new TwigFunction('is_guest', [$this, 'isGuest']), new TwigFunction('has_permission_to', [$this->auth, 'can']), ]; } /** * @return bool */ public function isAuthenticated() { return (bool)$this->auth->user(); } /** * @return bool */ public function isGuest() { return !$this->isAuthenticated(); } }