diff --git a/config/_config.php b/config/_config.php index 9583e0c2..1a356b9e 100644 --- a/config/_config.php +++ b/config/_config.php @@ -24,5 +24,16 @@ * @param string selfUpdate stable, latest */ 'installMode' => 'copy', - 'selfUpdate' => 'stable' + 'selfUpdate' => 'stable', + + /** + * Settings revolving around your modified-shop + * + * Overwrite the default shop path. If your MMLC installation is not inside + * of your modified-shop root and exists as a symbolic link, you may need to + * define your shop root here. + * + * Leave empty for default. + */ + 'shopRoot' => '', ]; diff --git a/src/Classes/Api/V1/HttpRequest.php b/src/Classes/Api/V1/HttpRequest.php index 1cf86f65..1d8da5db 100644 --- a/src/Classes/Api/V1/HttpRequest.php +++ b/src/Classes/Api/V1/HttpRequest.php @@ -46,7 +46,14 @@ public function sendPostRequest(string $url, $data) // Logging if ($this->logging) { - file_put_contents(App::getLogsRoot() . '/log.txt', $result); + $logFilepath = App::getLogsRoot() . '/log.txt'; + $logDirectory = dirname($logFilepath); + + if (!file_exists($logDirectory)) { + mkdir($logDirectory); + } + + file_put_contents($logFilepath, $result); } return $result; diff --git a/src/Classes/App.php b/src/Classes/App.php index 07476545..14790422 100644 --- a/src/Classes/App.php +++ b/src/Classes/App.php @@ -40,7 +40,7 @@ public static function getRoot(): string public static function getShopRoot(): string { - return realPath(__DIR__ . '/../../../'); + return Config::getShopRoot(); } public static function getSrcRoot(): string diff --git a/src/Classes/Config.php b/src/Classes/Config.php index a7dc7e40..4699fb0e 100644 --- a/src/Classes/Config.php +++ b/src/Classes/Config.php @@ -225,6 +225,26 @@ public static function setAdminDir(string $newAdminDir): void self::writeConfiguration(['adminDir' => $newAdminDir]); } + /** + * Get the modified-shop root directory. + * + * @return string + */ + public static function getShopRoot(): string + { + $shopRootOption = self::getOption('shopRoot'); + $shopRootDirectory = empty($shopRootOption) + ? realpath(__DIR__ . '/../../../') + : rtrim($shopRootOption, '/\\'); + + return $shopRootDirectory; + } + + public static function setShopRoot(string $newShopRoot): void + { + self::writeConfiguration(['shopRoot' => $newShopRoot]); + } + /** * Get modulesLocalDir from config. * diff --git a/src/Classes/IndexController.php b/src/Classes/IndexController.php index 8eb4a284..eb95ebd2 100644 --- a/src/Classes/IndexController.php +++ b/src/Classes/IndexController.php @@ -602,6 +602,10 @@ public function invokeSettings() Config::setAccessToken($parsedBody['accessToken']); } + if (isset($parsedBody['shopRoot'])) { + Config::setShopRoot($parsedBody['shopRoot']); + } + if (isset($parsedBody['modulesLocalDir'])) { Config::setModulesLocalDir($parsedBody['modulesLocalDir']); } diff --git a/src/Templates/Settings.tmpl.php b/src/Templates/Settings.tmpl.php index ec07e2c5..e10665c5 100644 --- a/src/Templates/Settings.tmpl.php +++ b/src/Templates/Settings.tmpl.php @@ -73,7 +73,7 @@ function viewIsSelected(bool $value): string
Mit diesem Namen meldest du dich im MMLC an.
- +