File modules/util/Request.class.php
Last commit: Fri Apr 15 14:51:22 2022 +0200 dankert Refactoring: User,Config and Database info is now stored in the Request, because so there is no session required for clients which are using Basic Authorization.
1 <?php 2 3 namespace util; 4 5 use cms\model\User; 6 use database\Database; 7 use security\Password; 8 9 10 /** 11 * Request 12 * 13 */ 14 class Request 15 { 16 private static $user; 17 private static $config; 18 private static $databaseId; 19 20 /** 21 * Database object. 22 * Request scope. 23 * @var 24 */ 25 private static $database; 26 27 public static function setConfig($config ) { 28 self::$config = $config; 29 Session::set( Session::KEY_CONFIG,$config ); 30 } 31 public static function getConfig() { 32 return self::$config ?: Session::get( Session::KEY_CONFIG ); 33 } 34 35 public static function setUser( $user ) { 36 self::$user = $user; 37 Session::set( Session::KEY_USER, $user ); 38 } 39 public static function getUser() { 40 return self::$user ?: Session::get( Session::KEY_USER ); 41 } 42 43 public static function getDatabaseId() { 44 return self::$databaseId ?: Session::get( Session::KEY_DBID ); 45 } 46 47 /** 48 * @return Database 49 */ 50 public static function getDatabase() 51 { 52 return self::$database; 53 } 54 55 /** 56 * @param $db Database 57 * @return void 58 */ 59 public static function setDatabase($db ) 60 { 61 self::$databaseId = $db->id; 62 Session::set( Session::KEY_DBID,self::$databaseId ); 63 64 self::$database = $db; 65 } 66 } 67
Downloadmodules/util/Request.class.php
History Fri, 15 Apr 2022 14:51:22 +0200 dankert Refactoring: User,Config and Database info is now stored in the Request, because so there is no session required for clients which are using Basic Authorization.