Prepare for embedded mode

This commit is contained in:
Bernd Bestel
2018-07-16 21:17:32 +02:00
parent db9ee93d2b
commit 3b4141eb4d
11 changed files with 36 additions and 15 deletions

View File

@@ -9,7 +9,15 @@ class ApplicationService extends BaseService
*/
public function IsDemoInstallation()
{
return file_exists(__DIR__ . '/../data/demo.txt');
return file_exists(DATAPATH . '/demo.txt');
}
/**
* @return boolean
*/
public function IsEmbeddedInstallation()
{
return file_exists(__DIR__ . '/../embedded.txt');
}
private $InstalledVersion;

View File

@@ -14,7 +14,7 @@ class DatabaseService
{
if ($this->DbConnectionRaw == null)
{
$pdo = new \PDO('sqlite:' . __DIR__ . '/../data/grocy.db');
$pdo = new \PDO('sqlite:' . DATAPATH . '/grocy.db');
$pdo->setAttribute(\PDO::ATTR_ERRMODE, \PDO::ERRMODE_EXCEPTION);
$this->DbConnectionRaw = $pdo;
}

View File

@@ -123,7 +123,7 @@ class DemoDataGeneratorService extends BaseService
public function RecreateDemo()
{
unlink(__DIR__ . '/../data/grocy.db');
unlink(DATAPATH . '/grocy.db');
$this->PopulateDemoData();
}
}

View File

@@ -36,7 +36,7 @@ class LocalizationService
private function LogMissingLocalization(string $culture, string $text)
{
$file = __DIR__ . "/../data/missing_translations_$culture.json";
$file = DATAPATH . "/missing_translations_$culture.json";
$missingTranslations = array();
if (file_exists($file))

View File

@@ -222,7 +222,7 @@ class StockService extends BaseService
throw new \Exception('No barcode lookup plugin defined');
}
$path = __DIR__ . "/../data/plugins/$pluginName.php";
$path = DATAPATH . "/plugins/$pluginName.php";
if (file_exists($path))
{
require_once $path;