Move about dialog into separate view and add API endpoint for system info

This commit is contained in:
Bernd Bestel
2019-02-09 13:41:40 +01:00
parent b5ac319a90
commit 01e9e3f5ce
9 changed files with 143 additions and 44 deletions

View File

@@ -0,0 +1,40 @@
<?php
namespace Grocy\Controllers;
use \Grocy\Services\ApplicationService;
use \Grocy\Services\DatabaseMigrationService;
use \Grocy\Services\DemoDataGeneratorService;
class SystemController extends BaseController
{
public function __construct(\Slim\Container $container)
{
parent::__construct($container);
$this->ApplicationService = new ApplicationService();
}
protected $ApplicationService;
public function Root(\Slim\Http\Request $request, \Slim\Http\Response $response, array $args)
{
// Schema migration is done here
$databaseMigrationService = new DatabaseMigrationService();
$databaseMigrationService->MigrateDatabase();
if (GROCY_IS_DEMO_INSTALL)
{
$demoDataGeneratorService = new DemoDataGeneratorService();
$demoDataGeneratorService->PopulateDemoData();
}
return $response->withRedirect($this->AppContainer->UrlManager->ConstructUrl('/stockoverview'));
}
public function About(\Slim\Http\Request $request, \Slim\Http\Response $response, array $args)
{
return $this->AppContainer->view->render($response, 'about', [
'system_info' => $this->ApplicationService->GetSystemInfo()
]);
}
}