2018-04-11 19:49:35 +02:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace Grocy\Services;
|
|
|
|
|
|
|
|
class BaseService
|
|
|
|
{
|
2020-08-31 20:40:31 +02:00
|
|
|
private static $instances = [];
|
2020-03-01 23:47:47 +07:00
|
|
|
|
|
|
|
public static function getInstance()
|
|
|
|
{
|
|
|
|
$className = get_called_class();
|
2020-08-31 20:40:31 +02:00
|
|
|
if (!isset(self::$instances[$className]))
|
2020-03-01 23:47:47 +07:00
|
|
|
{
|
|
|
|
self::$instances[$className] = new $className();
|
|
|
|
}
|
|
|
|
|
|
|
|
return self::$instances[$className];
|
|
|
|
}
|
|
|
|
|
2020-08-31 20:40:31 +02:00
|
|
|
protected function getBatteriesService()
|
2020-03-01 23:47:47 +07:00
|
|
|
{
|
2020-08-31 20:40:31 +02:00
|
|
|
return BatteriesService::getInstance();
|
|
|
|
}
|
|
|
|
|
|
|
|
protected function getChoresService()
|
|
|
|
{
|
|
|
|
return ChoresService::getInstance();
|
2020-03-01 23:47:47 +07:00
|
|
|
}
|
|
|
|
|
|
|
|
protected function getDatabase()
|
|
|
|
{
|
|
|
|
return $this->getDatabaseService()->GetDbConnection();
|
|
|
|
}
|
2018-07-14 22:49:42 +02:00
|
|
|
|
2020-08-31 20:40:31 +02:00
|
|
|
protected function getDatabaseService()
|
|
|
|
{
|
|
|
|
return DatabaseService::getInstance();
|
|
|
|
}
|
|
|
|
|
|
|
|
protected function getLocalizationService()
|
2020-03-01 23:47:47 +07:00
|
|
|
{
|
2020-11-08 21:37:43 +01:00
|
|
|
if (!defined('GROCY_LOCALE'))
|
|
|
|
{
|
|
|
|
define('GROCY_LOCALE', GROCY_DEFAULT_LOCALE);
|
|
|
|
}
|
|
|
|
|
2020-08-31 19:11:51 +02:00
|
|
|
return LocalizationService::getInstance(GROCY_LOCALE);
|
2018-04-11 19:49:35 +02:00
|
|
|
}
|
|
|
|
|
2025-01-11 20:04:32 +01:00
|
|
|
protected function getStockService()
|
2020-03-01 23:47:47 +07:00
|
|
|
{
|
|
|
|
return StockService::getInstance();
|
|
|
|
}
|
|
|
|
|
|
|
|
protected function getTasksService()
|
|
|
|
{
|
|
|
|
return TasksService::getInstance();
|
|
|
|
}
|
|
|
|
|
|
|
|
protected function getUsersService()
|
|
|
|
{
|
|
|
|
return UsersService::getInstance();
|
|
|
|
}
|
2021-06-18 20:45:42 +02:00
|
|
|
|
|
|
|
protected function getPrintService()
|
|
|
|
{
|
|
|
|
return PrintService::getInstance();
|
|
|
|
}
|
2025-01-11 20:04:32 +01:00
|
|
|
|
|
|
|
protected function getFilesService()
|
|
|
|
{
|
|
|
|
return FilesService::getInstance();
|
|
|
|
}
|
2025-01-12 13:58:47 +01:00
|
|
|
|
|
|
|
protected function getApplicationService()
|
|
|
|
{
|
|
|
|
return ApplicationService::getInstance();
|
|
|
|
}
|
2018-04-11 19:49:35 +02:00
|
|
|
}
|