Files
grocy/controllers/SystemController.php
T

107 lines
2.5 KiB
PHP
Raw Normal View History

<?php
namespace Grocy\Controllers;
2020-08-31 20:40:31 +02:00
use Grocy\Services\DatabaseMigrationService;
use Grocy\Services\DemoDataGeneratorService;
2023-05-13 14:43:51 +02:00
use Psr\Http\Message\ResponseInterface as Response;
use Psr\Http\Message\ServerRequestInterface as Request;
class SystemController extends BaseController
{
2023-05-13 14:43:51 +02:00
public function About(Request $request, Response $response, array $args)
2020-08-31 20:40:31 +02:00
{
return $this->renderPage($response, 'about', [
'system_info' => $this->getApplicationService()->GetSystemInfo(),
'changelog' => $this->getApplicationService()->GetChangelog()
]);
}
2023-05-13 14:43:51 +02:00
public function BarcodeScannerTesting(Request $request, Response $response, array $args)
{
2020-08-31 20:40:31 +02:00
return $this->renderPage($response, 'barcodescannertesting');
}
2023-05-13 14:43:51 +02:00
public function Root(Request $request, Response $response, array $args)
{
// Schema migration is done here
$databaseMigrationService = DatabaseMigrationService::getInstance();
$databaseMigrationService->MigrateDatabase();
if (GROCY_MODE === 'dev' || GROCY_MODE === 'demo' || GROCY_MODE === 'prerelease')
{
$demoDataGeneratorService = DemoDataGeneratorService::getInstance();
$demoDataGeneratorService->PopulateDemoData();
}
2020-02-11 17:42:03 +01:00
return $response->withRedirect($this->AppContainer->get('UrlManager')->ConstructUrl($this->GetEntryPageRelative()));
}
private function GetEntryPageRelative()
{
2020-08-31 20:40:31 +02:00
if (defined('GROCY_ENTRY_PAGE'))
{
$entryPage = constant('GROCY_ENTRY_PAGE');
2020-08-31 20:40:31 +02:00
}
else
{
$entryPage = 'stock';
}
2020-09-01 21:29:47 +02:00
// Stock
2020-08-31 20:40:31 +02:00
if ($entryPage === 'stock' && constant('GROCY_FEATURE_FLAG_STOCK'))
{
return '/stockoverview';
}
2020-09-01 21:29:47 +02:00
// Shoppinglist
2020-08-31 20:40:31 +02:00
if ($entryPage === 'shoppinglist' && constant('GROCY_FEATURE_FLAG_SHOPPINGLIST'))
{
return '/shoppinglist';
}
2020-09-01 21:29:47 +02:00
// Recipes
2020-08-31 20:40:31 +02:00
if ($entryPage === 'recipes' && constant('GROCY_FEATURE_FLAG_RECIPES'))
{
return '/recipes';
}
2020-09-01 21:29:47 +02:00
// Chores
2020-08-31 20:40:31 +02:00
if ($entryPage === 'chores' && constant('GROCY_FEATURE_FLAG_CHORES'))
{
return '/choresoverview';
}
2020-09-01 21:29:47 +02:00
// Tasks
2020-08-31 20:40:31 +02:00
if ($entryPage === 'tasks' && constant('GROCY_FEATURE_FLAG_TASKS'))
{
return '/tasks';
}
2020-09-01 21:29:47 +02:00
// Batteries
2020-08-31 20:40:31 +02:00
if ($entryPage === 'batteries' && constant('GROCY_FEATURE_FLAG_BATTERIES'))
{
return '/batteriesoverview';
}
2020-08-31 20:40:31 +02:00
if ($entryPage === 'equipment' && constant('GROCY_FEATURE_FLAG_EQUIPMENT'))
{
return '/equipment';
}
2020-09-01 21:29:47 +02:00
// Calendar
2020-08-31 20:40:31 +02:00
if ($entryPage === 'calendar' && constant('GROCY_FEATURE_FLAG_CALENDAR'))
{
return '/calendar';
}
2020-09-01 21:29:47 +02:00
// Meal Plan
if ($entryPage === 'mealplan' && constant('GROCY_FEATURE_FLAG_RECIPES_MEALPLAN'))
2020-08-31 20:40:31 +02:00
{
2019-09-25 12:08:41 +01:00
return '/mealplan';
}
return '/about';
}
}