Skip to content

Commit

Permalink
Minor updates
Browse files Browse the repository at this point in the history
  • Loading branch information
eugabrielsilva committed Apr 1, 2024
1 parent d622178 commit 6d5ef07
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
7 changes: 6 additions & 1 deletion src/Tools/Authenticator.php
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}

/**
Expand Down
2 changes: 1 addition & 1 deletion src/View/Skeltch.php
Original file line number Diff line number Diff line change
Expand Up @@ -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*foreach\s*\((.+?)\s+as\s+(.+?)(\s+=> (.*?))?\)\s*}~is', function($matches){
return preg_replace_callback('~(?<!@){\s*foreach\s*\((.+?)\s+as\s+(.+?)(\s+=>\s+(.*?))?\)\s*}~is', function($matches){
if(isset($matches[4])){
return sprintf('<?php \Glowie\Core\View\Skeltch::resetLoop(); foreach(%s as %s => %s): $loop = \Glowie\Core\View\Skeltch::getLoop(%s); ?>', $matches[1], $matches[2], $matches[4], $matches[1]);
}else{
Expand Down

0 comments on commit 6d5ef07

Please sign in to comment.