*/
protected static $current_token = [];
+ /**
+ * Get current user id, returns 0 if $login is set to false and not logged in.
+ * When $login is true, the execution will stop when not logged in.
+ *
+ * @param bool $login Perform a login request if "true"
+ *
+ * @return int User ID
+ */
+ public static function getCurrentUserID(bool $login)
+ {
+ if (empty(self::$current_user_id)) {
+ api_login(DI::app(), $login);
+
+ self::$current_user_id = api_user();
+ }
+
+ return (int)self::$current_user_id;
+ }
+
/**
* Fetch a dummy application token
*
*/
public static function getCurrentApplicationToken()
{
- if (empty(self::getCurrentUserID())) {
+ if (empty(self::getCurrentUserID(true))) {
return [];
}
return self::$current_token;
}
-
- /**
- * Get current user id, returns 0 if $login is set to false and not logged in.
- * When $login is true, the execution will stop when not logged in.
- *
- * @param bool $login Perform a login request if "true"
- *
- * @return int User ID
- */
- public static function getCurrentUserID(bool $login = true)
- {
- if (empty(self::$current_user_id)) {
- api_login(DI::app(), $login);
-
- self::$current_user_id = api_user();
- }
-
- return (int)self::$current_user_id;
- }
}