mirror of
https://github.com/grocy/grocy.git
synced 2026-04-05 12:26:15 +02:00
utilise Localisation service as a singleton
This commit is contained in:
parent
aa1cc4ad88
commit
9f277f51b3
8
app.php
8
app.php
|
|
@ -74,11 +74,11 @@ $appContainer = new \Slim\Container([
|
|||
]);
|
||||
$app = new \Slim\App($appContainer);
|
||||
|
||||
$fp = fopen('/www/data/sql.log', 'a');
|
||||
fwrite($fp, "!!!Starting up loading app\n");
|
||||
fwrite($fp, "!!!".print_r(ini_get_all(),True)."\n");
|
||||
#$fp = fopen('/www/data/sql.log', 'a');
|
||||
#fwrite($fp, "!!!Starting up loading app\n");
|
||||
#fwrite($fp, "!!!".print_r(ini_get_all(),True)."\n");
|
||||
#fwrite($fp, "!!!".print_r(opcache_get_status(),True)."\n");
|
||||
fclose($fp);
|
||||
#fclose($fp);
|
||||
|
||||
phpinfo();
|
||||
|
||||
|
|
|
|||
|
|
@ -13,7 +13,7 @@ class BaseController
|
|||
$databaseService = DatabaseService::getInstance();
|
||||
$this->Database = $databaseService->GetDbConnection();
|
||||
|
||||
$localizationService = new LocalizationService(GROCY_CULTURE);
|
||||
$localizationService = LocalizationService::getInstance(GROCY_CULTURE);
|
||||
$this->LocalizationService = $localizationService;
|
||||
|
||||
$applicationService = ApplicationService::getInstance();
|
||||
|
|
|
|||
|
|
@ -32,7 +32,7 @@ class ApiKeyAuthMiddleware extends BaseMiddleware
|
|||
$validSession = true;
|
||||
$validApiKey = true;
|
||||
$usedApiKey = null;
|
||||
|
||||
|
||||
$sessionService = new SessionService();
|
||||
if (!isset($_COOKIE[$this->SessionCookieName]) || !$sessionService->IsValidSession($_COOKIE[$this->SessionCookieName]))
|
||||
{
|
||||
|
|
|
|||
|
|
@ -11,7 +11,7 @@ class BaseService
|
|||
$this->DatabaseService = DatabaseService::getInstance();
|
||||
$this->Database = $this->DatabaseService->GetDbConnection();
|
||||
|
||||
$localizationService = new LocalizationService(GROCY_CULTURE);
|
||||
$localizationService = LocalizationService::getInstance(GROCY_CULTURE);
|
||||
$this->LocalizationService = $localizationService;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -11,9 +11,9 @@ class FilesService extends BaseService
|
|||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
|
||||
|
||||
$this->StoragePath = GROCY_DATAPATH . '/storage';
|
||||
|
||||
|
||||
if (!file_exists($this->StoragePath))
|
||||
{
|
||||
mkdir($this->StoragePath);
|
||||
|
|
|
|||
|
|
@ -9,6 +9,9 @@ use \Gettext\Translator;
|
|||
|
||||
class LocalizationService
|
||||
{
|
||||
|
||||
private static $instanceMap = array();
|
||||
|
||||
public function __construct(string $culture)
|
||||
{
|
||||
$this->Culture = $culture;
|
||||
|
|
@ -18,6 +21,16 @@ class LocalizationService
|
|||
$this->LoadLocalizations($culture);
|
||||
}
|
||||
|
||||
public static function getInstance(string $culture)
|
||||
{
|
||||
if (!in_array($culture, self::$instanceMap))
|
||||
{
|
||||
self::$instanceMap[$culture] = new self($culture);
|
||||
}
|
||||
|
||||
return self::$instanceMap[$culture];
|
||||
}
|
||||
|
||||
protected $DatabaseService;
|
||||
protected $Database;
|
||||
protected $Pot;
|
||||
|
|
|
|||
|
|
@ -41,7 +41,7 @@ class SessionService extends BaseService
|
|||
public function CreateSession($userId, $stayLoggedInPermanently = false)
|
||||
{
|
||||
$newSessionKey = $this->GenerateSessionKey();
|
||||
|
||||
|
||||
$expires = date('Y-m-d H:i:s', intval(time() + 2592000)); // Default is that sessions expire in 30 days
|
||||
if ($stayLoggedInPermanently === true)
|
||||
{
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user