mirror of
https://github.com/grocy/grocy.git
synced 2025-08-20 20:26:42 +00:00
Reorganize project part 2
This commit is contained in:
67
controllers/HabitsController.php
Normal file
67
controllers/HabitsController.php
Normal file
@@ -0,0 +1,67 @@
|
||||
<?php
|
||||
|
||||
namespace Grocy\Controllers;
|
||||
|
||||
use Grocy\Services\HabitsService;
|
||||
|
||||
class HabitsController extends BaseController
|
||||
{
|
||||
public function __construct(\Slim\Container $container)
|
||||
{
|
||||
parent::__construct($container);
|
||||
$this->HabitsService = new HabitsService();
|
||||
}
|
||||
|
||||
protected $HabitsService;
|
||||
|
||||
public function Overview($request, $response, $args)
|
||||
{
|
||||
return $this->AppContainer->view->render($response, 'habitsoverview', [
|
||||
'title' => 'Habits overview',
|
||||
'contentPage' => 'habitsoverview.php',
|
||||
'habits' => $this->Database->habits(),
|
||||
'currentHabits' => $this->HabitsService->GetCurrentHabits(),
|
||||
]);
|
||||
}
|
||||
|
||||
public function TrackHabitExecution($request, $response, $args)
|
||||
{
|
||||
return $this->AppContainer->view->render($response, 'habittracking', [
|
||||
'title' => 'Habit tracking',
|
||||
'contentPage' => 'habittracking.php',
|
||||
'habits' => $this->Database->habits()
|
||||
]);
|
||||
}
|
||||
|
||||
public function HabitsList($request, $response, $args)
|
||||
{
|
||||
return $this->AppContainer->view->render($response, 'habits', [
|
||||
'title' => 'Habits',
|
||||
'contentPage' => 'habits.php',
|
||||
'habits' => $this->Database->habits()
|
||||
]);
|
||||
}
|
||||
|
||||
public function HabitEditForm($request, $response, $args)
|
||||
{
|
||||
if ($args['habitId'] == 'new')
|
||||
{
|
||||
return $this->AppContainer->view->render($response, 'habitform', [
|
||||
'title' => 'Create habit',
|
||||
'contentPage' => 'habitform.php',
|
||||
'periodTypes' => GetClassConstants('Grocy\Services\HabitsService'),
|
||||
'mode' => 'create'
|
||||
]);
|
||||
}
|
||||
else
|
||||
{
|
||||
return $this->AppContainer->view->render($response, 'habitform', [
|
||||
'title' => 'Edit habit',
|
||||
'contentPage' => 'habitform.php',
|
||||
'habit' => $this->Database->habits($args['habitId']),
|
||||
'periodTypes' => GetClassConstants('Grocy\Services\HabitsService'),
|
||||
'mode' => 'edit'
|
||||
]);
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user