Applied EditorConfig settings to all files

This commit is contained in:
Bernd Bestel
2020-08-29 16:41:27 +02:00
parent 2c966c77fd
commit 3b0d29bed0
87 changed files with 797 additions and 798 deletions

View File

@@ -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();
}

View File

@@ -35,7 +35,7 @@ class ChoresService extends BaseService
{
throw new \Exception('Chore does not exist');
}
$users = $this->getUsersService()->GetUsersAsDto();
$chore = $this->getDatabase()->chores($choreId);

View File

@@ -28,7 +28,7 @@ class DatabaseService
return GROCY_DATAPATH . '/grocy.db';
}
private static $DbConnectionRaw = null;
private static $DbConnectionRaw = null;
/**
* @return \PDO
*/

View File

@@ -12,7 +12,7 @@ class DemoDataGeneratorService extends BaseService
$this->LocalizationService = new LocalizationService(GROCY_CULTURE);
}
protected $LocalizationService;
protected $LocalizationService;
public function PopulateDemoData()
{

View File

@@ -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"));

View File

@@ -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)
{

View File

@@ -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)
{

View File

@@ -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)