comments in controllers hinzugefügt + review + testing

This commit is contained in:
arslandevelopments
2026-08-19 14:01:43 +02:00
parent 6e1dcd9d1c
commit f91feadedf
5 changed files with 30 additions and 7 deletions
+9 -1
View File
@@ -2,6 +2,7 @@
class HabitController
{
// Zeigt das Dashboard mit allen Habits des Benutzers
public function dashboard(): void
{
require_login();
@@ -26,6 +27,7 @@ class HabitController
]);
}
// Zeigt das leere Formular zum Anlegen
public function create(): void
{
require_login();
@@ -37,6 +39,7 @@ class HabitController
]);
}
// Speichert einen neuen Habit
public function store(): void
{
require_login();
@@ -58,6 +61,7 @@ class HabitController
redirect('dashboard');
}
// Zeigt das Formular zum Bearbeiten
public function edit(): void
{
require_login();
@@ -76,6 +80,7 @@ class HabitController
]);
}
// Uebernimmt die Aenderungen eines bestehenden Habits
public function update(): void
{
require_login();
@@ -85,6 +90,7 @@ class HabitController
$data = $this->validatedData();
if (!empty($data['errors'])) {
// ID mitgeben, sonst zeigt das Formular auf keinen Datensatz mehr
View::render('habits/form', [
'habit' => array_merge($_POST, ['id' => $id]),
'categories' => Category::all(),
@@ -98,6 +104,7 @@ class HabitController
redirect('dashboard');
}
// Loescht einen Habit
public function delete(): void
{
require_login();
@@ -135,6 +142,7 @@ class HabitController
$errors['description'] = 'Die Beschreibung darf maximal 1000 Zeichen lang sein.';
}
// Gegen die Datenbank pruefen, damit keine erfundene ID durchkommt
if ($categoryId !== '' && !Category::exists((int) $categoryId)) {
$errors['category_id'] = 'Bitte waehle eine gueltige Kategorie aus.';
}
@@ -151,4 +159,4 @@ class HabitController
'errors' => $errors,
];
}
}
}