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, 'checkAuth']), ]; } /** * @return bool */ public function isAuthenticated() { return (bool)$this->auth->user(); } /** * @return bool */ public function isGuest() { return !$this->isAuthenticated(); } /** * @param $privilege * @return bool */ public function checkAuth($privilege) { global $privileges; return in_array($privilege, $privileges); } }