grocy/services/BaseService.php
Mark Garratt 6b833d178d Begin refactoring WebhookRunner into WebhookService
The plan is to enable multiple webhooks to be called for different
events which will allow integration with other services without having
to poll for changes.
2025-01-17 19:27:43 +00:00

85 lines
1.4 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();
}
protected function getFilesService()
{
return FilesService::getInstance();
}
protected function getApplicationService()
{
return ApplicationService::getInstance();
}
protected function getWebhookService()
{
return WebhookService::getInstance();
}
}