mirror of
https://github.com/grocy/grocy.git
synced 2025-08-20 04:12:59 +00:00
Applied EditorConfig settings to all files
This commit is contained in:
@@ -15,7 +15,7 @@ class BaseService
|
||||
public static function getInstance()
|
||||
{
|
||||
$className = get_called_class();
|
||||
if(!isset(self::$instances[$className]))
|
||||
if(!isset(self::$instances[$className]))
|
||||
{
|
||||
self::$instances[$className] = new $className();
|
||||
}
|
||||
@@ -23,7 +23,7 @@ class BaseService
|
||||
return self::$instances[$className];
|
||||
}
|
||||
|
||||
protected function getDatabaseService()
|
||||
protected function getDatabaseService()
|
||||
{
|
||||
return DatabaseService::getInstance();
|
||||
}
|
||||
|
@@ -35,7 +35,7 @@ class ChoresService extends BaseService
|
||||
{
|
||||
throw new \Exception('Chore does not exist');
|
||||
}
|
||||
|
||||
|
||||
$users = $this->getUsersService()->GetUsersAsDto();
|
||||
|
||||
$chore = $this->getDatabase()->chores($choreId);
|
||||
|
@@ -28,7 +28,7 @@ class DatabaseService
|
||||
return GROCY_DATAPATH . '/grocy.db';
|
||||
}
|
||||
|
||||
private static $DbConnectionRaw = null;
|
||||
private static $DbConnectionRaw = null;
|
||||
/**
|
||||
* @return \PDO
|
||||
*/
|
||||
|
@@ -12,7 +12,7 @@ class DemoDataGeneratorService extends BaseService
|
||||
$this->LocalizationService = new LocalizationService(GROCY_CULTURE);
|
||||
}
|
||||
|
||||
protected $LocalizationService;
|
||||
protected $LocalizationService;
|
||||
|
||||
public function PopulateDemoData()
|
||||
{
|
||||
|
@@ -21,16 +21,16 @@ class LocalizationService
|
||||
|
||||
|
||||
protected function getDatabaseService()
|
||||
{
|
||||
return DatabaseService::getInstance();
|
||||
}
|
||||
{
|
||||
return DatabaseService::getInstance();
|
||||
}
|
||||
|
||||
protected function getdatabase()
|
||||
{
|
||||
return $this->getDatabaseService()->GetDbConnection();
|
||||
}
|
||||
protected function getdatabase()
|
||||
{
|
||||
return $this->getDatabaseService()->GetDbConnection();
|
||||
}
|
||||
|
||||
public static function getInstance(string $culture)
|
||||
public static function getInstance(string $culture)
|
||||
{
|
||||
if (!in_array($culture, self::$instanceMap))
|
||||
{
|
||||
@@ -92,10 +92,10 @@ class LocalizationService
|
||||
{
|
||||
$this->Po = $this->Po->mergeWith(Translations::fromPoFile(__DIR__ . "/../localization/$culture/userfield_types.po"));
|
||||
}
|
||||
if (file_exists(__DIR__ . "/../localization/$culture/permissions.po"))
|
||||
{
|
||||
$this->Po = $this->Po->mergeWith(Translations::fromPoFile(__DIR__ . "/../localization/$culture/permissions.po"));
|
||||
}
|
||||
if (file_exists(__DIR__ . "/../localization/$culture/permissions.po"))
|
||||
{
|
||||
$this->Po = $this->Po->mergeWith(Translations::fromPoFile(__DIR__ . "/../localization/$culture/permissions.po"));
|
||||
}
|
||||
if (GROCY_MODE !== 'production' && file_exists(__DIR__ . "/../localization/$culture/demo_data.po"))
|
||||
{
|
||||
$this->Po = $this->Po->mergeWith(Translations::fromPoFile(__DIR__ . "/../localization/$culture/demo_data.po"));
|
||||
|
@@ -14,16 +14,16 @@ class StockService extends BaseService
|
||||
const TRANSACTION_TYPE_PRODUCT_OPENED = 'product-opened';
|
||||
const TRANSACTION_TYPE_SELF_PRODUCTION = 'self-production';
|
||||
|
||||
public function GetCurrentStockOverview()
|
||||
{
|
||||
if (!GROCY_FEATURE_SETTING_STOCK_COUNT_OPENED_PRODUCTS_AGAINST_MINIMUM_STOCK_AMOUNT) {
|
||||
return $this->getDatabase()->uihelper_stock_current_overview();
|
||||
} else {
|
||||
return $this->getDatabase()->uihelper_stock_current_overview_including_opened();
|
||||
}
|
||||
}
|
||||
public function GetCurrentStockOverview()
|
||||
{
|
||||
if (!GROCY_FEATURE_SETTING_STOCK_COUNT_OPENED_PRODUCTS_AGAINST_MINIMUM_STOCK_AMOUNT) {
|
||||
return $this->getDatabase()->uihelper_stock_current_overview();
|
||||
} else {
|
||||
return $this->getDatabase()->uihelper_stock_current_overview_including_opened();
|
||||
}
|
||||
}
|
||||
|
||||
public function GetCurrentStock($includeNotInStockButMissingProducts = false)
|
||||
public function GetCurrentStock($includeNotInStockButMissingProducts = false)
|
||||
{
|
||||
$sql = 'SELECT * FROM stock_current';
|
||||
if ($includeNotInStockButMissingProducts)
|
||||
@@ -37,7 +37,7 @@ class StockService extends BaseService
|
||||
$sql = 'SELECT * FROM stock_current WHERE best_before_date IS NOT NULL UNION SELECT id, 0, 0, 0, 0, null, 0, 0, 0 FROM ' . $missingProductsView . ' WHERE id NOT IN (SELECT product_id FROM stock_current)';
|
||||
}
|
||||
$currentStockMapped = $this->getDatabaseService()->ExecuteDbQuery($sql)->fetchAll(\PDO::FETCH_GROUP|\PDO::FETCH_OBJ);
|
||||
|
||||
|
||||
$relevantProducts = $this->getDatabase()->products()->where('id IN (SELECT product_id FROM (' . $sql . ') x)');
|
||||
foreach ($relevantProducts as $product)
|
||||
{
|
||||
|
@@ -23,13 +23,13 @@ class UserfieldsService extends BaseService
|
||||
protected $OpenApiSpec = null;
|
||||
|
||||
protected function getOpenApispec()
|
||||
{
|
||||
if($this->OpenApiSpec == null)
|
||||
{
|
||||
$this->OpenApiSpec = json_decode(file_get_contents(__DIR__ . '/../grocy.openapi.json'));
|
||||
}
|
||||
return $this->OpenApiSpec;
|
||||
}
|
||||
{
|
||||
if($this->OpenApiSpec == null)
|
||||
{
|
||||
$this->OpenApiSpec = json_decode(file_get_contents(__DIR__ . '/../grocy.openapi.json'));
|
||||
}
|
||||
return $this->OpenApiSpec;
|
||||
}
|
||||
|
||||
public function GetFields($entity)
|
||||
{
|
||||
|
@@ -12,17 +12,17 @@ class UsersService extends BaseService
|
||||
'last_name' => $lastName,
|
||||
'password' => password_hash($password, PASSWORD_DEFAULT)
|
||||
));
|
||||
$newUserRow = $newUserRow->save();
|
||||
$permList = array();
|
||||
foreach ($this->getDatabase()->permission_hierarchy()->where('name', GROCY_DEFAULT_PERMISSIONS)->fetchAll() as $perm) {
|
||||
$permList[] = array(
|
||||
'user_id' => $newUserRow->id,
|
||||
'permission_id' => $perm->id
|
||||
);
|
||||
}
|
||||
$this->getDatabase()->user_permissions()->insert($permList);
|
||||
$newUserRow = $newUserRow->save();
|
||||
$permList = array();
|
||||
foreach ($this->getDatabase()->permission_hierarchy()->where('name', GROCY_DEFAULT_PERMISSIONS)->fetchAll() as $perm) {
|
||||
$permList[] = array(
|
||||
'user_id' => $newUserRow->id,
|
||||
'permission_id' => $perm->id
|
||||
);
|
||||
}
|
||||
$this->getDatabase()->user_permissions()->insert($permList);
|
||||
|
||||
return $newUserRow;
|
||||
return $newUserRow;
|
||||
}
|
||||
|
||||
public function EditUser(int $userId, string $username, string $firstName, string $lastName, string $password)
|
||||
|
Reference in New Issue
Block a user