grocy/services/BaseService.php
fipwmaqzufheoxq92ebc 6f8ad9b76e
Locales: use http-accept-language or cookie (#976)
* Locales: use http-accept-language or "language"-cookie

* Add user-setting "locale"

Rename CULTURE to DEFAULT_LOCALE

* Use LocaleMiddleware also in dev mode

* CORS: don't require authentication on OPTIONS

* Use a standard user-settings-control and start a new generic user settings page, not a separate page for the locale setting

* Fixed (broken by myself) link-return handling

* Clarify language settings

* Removed unneeded files

* Better user settings icon

* Added localization hints

Co-authored-by: Bernd Bestel <bernd@berrnd.de>
2020-08-31 19:11:51 +02:00

66 lines
1.1 KiB
PHP

<?php
namespace Grocy\Services;
#use \Grocy\Services\DatabaseService;
#use \Grocy\Services\LocalizationService;
class BaseService
{
public function __construct() {
}
private static $instances = array();
public static function getInstance()
{
$className = get_called_class();
if(!isset(self::$instances[$className]))
{
self::$instances[$className] = new $className();
}
return self::$instances[$className];
}
protected function getDatabaseService()
{
return DatabaseService::getInstance();
}
protected function getDatabase()
{
return $this->getDatabaseService()->GetDbConnection();
}
protected function getLocalizationService()
{
return LocalizationService::getInstance(GROCY_LOCALE);
}
protected function getStockservice()
{
return StockService::getInstance();
}
protected function getTasksService()
{
return TasksService::getInstance();
}
protected function getChoresService()
{
return ChoresService::getInstance();
}
protected function getBatteriesService()
{
return BatteriesService::getInstance();
}
protected function getUsersService()
{
return UsersService::getInstance();
}
}