grocy/services/BaseService.php
Bernd Bestel edfa404ed6
Squashed commit
Always execute migration 9999 (can be used to fix things manually)
Optimized meal plan navigation / date range filtering
Prepared next release
Pulled translations from Transifex
Various code optimizations
2021-07-16 17:32:08 +02:00

70 lines
1.2 KiB
PHP

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