From 6d5ef07b83b6c93e494e88ba9bd2e6036b1e96b6 Mon Sep 17 00:00:00 2001 From: Gabriel Oliveira Date: Mon, 1 Apr 2024 16:54:41 -0300 Subject: [PATCH] Minor updates --- src/Tools/Authenticator.php | 7 ++++++- src/View/Skeltch.php | 2 +- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/src/Tools/Authenticator.php b/src/Tools/Authenticator.php index 8fb182a..4c5a55c 100644 --- a/src/Tools/Authenticator.php +++ b/src/Tools/Authenticator.php @@ -135,7 +135,12 @@ public function getUser(){ * @return mixed Returns the primary key value if authenticated, null otherwise. */ public function getUserId(){ - return self::$user ? self::$user->getPrimary() : null; + if(!self::$user){ + $user = $this->getUser(); + if(!$user) return null; + } + + return self::$user->getPrimary(); } /** diff --git a/src/View/Skeltch.php b/src/View/Skeltch.php index e483909..261e21b 100644 --- a/src/View/Skeltch.php +++ b/src/View/Skeltch.php @@ -188,7 +188,7 @@ private static function compileLoops(string $code){ * @return string Returns the compiled code. */ private static function compileForEachs(string $code){ - return preg_replace_callback('~(? (.*?))?\)\s*}~is', function($matches){ + return preg_replace_callback('~(?\s+(.*?))?\)\s*}~is', function($matches){ if(isset($matches[4])){ return sprintf(' %s): $loop = \Glowie\Core\View\Skeltch::getLoop(%s); ?>', $matches[1], $matches[2], $matches[4], $matches[1]); }else{