Optimized imports

This commit is contained in:
Bernd Bestel
2023-05-13 14:43:51 +02:00
parent 491412807c
commit dd5bd3852a
38 changed files with 241 additions and 282 deletions

View File

@@ -8,9 +8,6 @@ class ApiKeyService extends BaseService
const API_KEY_TYPE_SPECIAL_PURPOSE_CALENDAR_ICAL = 'special-purpose-calendar-ical';
/**
* @return string
*/
public function CreateApiKey($keyType = self::API_KEY_TYPE_DEFAULT)
{
$newApiKey = $this->GenerateApiKey();
@@ -67,9 +64,6 @@ class ApiKeyService extends BaseService
return null;
}
/**
* @return boolean
*/
public function IsValidApiKey($apiKey, $keyType = self::API_KEY_TYPE_DEFAULT)
{
if ($apiKey === null || empty($apiKey))

View File

@@ -102,11 +102,6 @@ class ApplicationService extends BaseService
}
}
/**
* Returns the response for the API call /system/time
* @param int $offset an offset in seconds to be applied
* @return array
*/
public function GetSystemTime(int $offset = 0): array
{
$timestamp = time() + $offset;

View File

@@ -3,6 +3,7 @@
namespace Grocy\Services;
use Grocy\Services\UsersService;
use LessQL\Database;
class DatabaseService
{
@@ -12,9 +13,6 @@ class DatabaseService
private static $instance = null;
/**
* @return boolean|\PDOStatement
*/
public function ExecuteDbQuery(string $sql)
{
$pdo = $this->GetDbConnectionRaw();
@@ -27,9 +25,6 @@ class DatabaseService
return false;
}
/**
* @return boolean
*/
public function ExecuteDbStatement(string $sql)
{
$pdo = $this->GetDbConnectionRaw();
@@ -47,22 +42,16 @@ class DatabaseService
return date('Y-m-d H:i:s', filemtime($this->GetDbFilePath()));
}
/**
* @return \LessQL\Database
*/
public function GetDbConnection()
{
if (self::$DbConnection == null)
{
self::$DbConnection = new \LessQL\Database($this->GetDbConnectionRaw());
self::$DbConnection = new Database($this->GetDbConnectionRaw());
}
return self::$DbConnection;
}
/**
* @return \PDO
*/
public function GetDbConnectionRaw()
{
if (self::$DbConnectionRaw == null)

View File

@@ -10,12 +10,6 @@ use Mike42\Escpos\Printer;
class PrintService extends BaseService
{
/**
* @param bool $printHeader Printing of Grocy logo
* @param string[] $lines Items to print
* @return string[] Returns array with result OK if no exception
* @throws Exception If unable to print, an exception is thrown
*/
public function printShoppingList(bool $printHeader, array $lines): array
{
$printer = self::getPrinterHandle();
@@ -43,11 +37,6 @@ class PrintService extends BaseService
];
}
/**
* Initialises the printer
* @return Printer Printer handle
* @throws Exception If unable to connect to printer, an exception is thrown
*/
private static function getPrinterHandle()
{
if (GROCY_TPRINTER_IS_NETWORK_PRINTER)
@@ -61,10 +50,6 @@ class PrintService extends BaseService
return new Printer($connector);
}
/**
* Prints the grocy logo and date
* @param Printer $printer Printer handle
*/
private static function printHeader(Printer $printer)
{
$date = new DateTime();

View File

@@ -6,9 +6,6 @@ class SessionService extends BaseService
{
const SESSION_COOKIE_NAME = 'grocy_session';
/**
* @return string
*/
public function CreateSession($userId, $stayLoggedInPermanently = false)
{
$newSessionKey = $this->GenerateSessionKey();
@@ -46,9 +43,6 @@ class SessionService extends BaseService
return null;
}
/**
* @return boolean
*/
public function IsValidSession($sessionKey)
{
if ($sessionKey === null || empty($sessionKey))

View File

@@ -1159,12 +1159,6 @@ class StockService extends BaseService
}
}
/**
* Returns the shoppinglist as an array with lines for a printer
* @param int $listId ID of shopping list
* @return string[] Returns an array in the format "[amount] [name of product]"
* @throws \Exception
*/
public function GetShoppinglistInPrintableStrings($listId = 1): array
{
if (!$this->ShoppingListExists($listId))

View File

@@ -2,9 +2,11 @@
namespace Grocy\Services;
use LessQL\Result
class TasksService extends BaseService
{
public function GetCurrent(): \LessQL\Result
public function GetCurrent(): Result
{
$users = $this->getUsersService()->GetUsersAsDto();
$categories = $this->getDatabase()->task_categories()->where('active = 1');

View File

@@ -2,6 +2,8 @@
namespace Grocy\Services;
use LessQL\Result;
class UsersService extends BaseService
{
public function CreateUser(string $username, ?string $firstName, ?string $lastName, string $password, string $pictureFileName = null)
@@ -102,7 +104,7 @@ class UsersService extends BaseService
return array_merge($GROCY_DEFAULT_USER_SETTINGS, $settings);
}
public function GetUsersAsDto(): \LessQL\Result
public function GetUsersAsDto(): Result
{
return $this->getDatabase()->users_dto();
}