comments in controllers hinzugefügt + review + testing
This commit is contained in:
Regular → Executable
+10
-4
@@ -2,6 +2,7 @@
|
||||
|
||||
class ReminderController
|
||||
{
|
||||
// Zeigt das Formular zum Anlegen einer Erinnerung
|
||||
public function create(): void
|
||||
{
|
||||
require_login();
|
||||
@@ -20,6 +21,7 @@ class ReminderController
|
||||
]);
|
||||
}
|
||||
|
||||
// Speichert eine neue Erinnerung
|
||||
public function store(): void
|
||||
{
|
||||
require_login();
|
||||
@@ -52,6 +54,7 @@ class ReminderController
|
||||
redirect('dashboard');
|
||||
}
|
||||
|
||||
// Zeigt das Formular zum Bearbeiten
|
||||
public function edit(): void
|
||||
{
|
||||
require_login();
|
||||
@@ -105,6 +108,7 @@ class ReminderController
|
||||
redirect('dashboard');
|
||||
}
|
||||
|
||||
// Loescht eine Erinnerung
|
||||
public function delete(): void
|
||||
{
|
||||
require_login();
|
||||
@@ -144,10 +148,12 @@ class ReminderController
|
||||
$activeValue = $this->postString('is_active');
|
||||
$errors = [];
|
||||
|
||||
if (!preg_match('/^(?:[01]\\d|2[0-3]):[0-5]\\d$/', $time)) {
|
||||
// Uhrzeit muss dem Format HH:MM zwischen 00:00 und 23:59
|
||||
if (!preg_match('/^(?:[01]\d|2[0-3]):[0-5]\d$/', $time)) {
|
||||
$errors['reminder_time'] = 'Bitte gib eine Uhrzeit im Format HH:MM ein.';
|
||||
}
|
||||
|
||||
// Leerer Wochentag ist erlaubt und bedeutet taeglich
|
||||
if ($weekdayValue !== '' && !preg_match('/^[1-7]$/', $weekdayValue)) {
|
||||
$errors['weekday'] = 'Bitte waehle einen gueltigen Wochentag aus.';
|
||||
}
|
||||
@@ -168,14 +174,14 @@ class ReminderController
|
||||
{
|
||||
$value = $_GET[$key] ?? '';
|
||||
|
||||
return is_string($value) && preg_match('/^[1-9]\\d*$/', $value) ? (int) $value : 0;
|
||||
return is_string($value) && preg_match('/^[1-9]\d*$/', $value) ? (int) $value : 0;
|
||||
}
|
||||
|
||||
private function postId(string $key): int
|
||||
{
|
||||
$value = $_POST[$key] ?? '';
|
||||
|
||||
return is_string($value) && preg_match('/^[1-9]\\d*$/', $value) ? (int) $value : 0;
|
||||
return is_string($value) && preg_match('/^[1-9]\d*$/', $value) ? (int) $value : 0;
|
||||
}
|
||||
|
||||
private function postString(string $key): string
|
||||
@@ -184,4 +190,4 @@ class ReminderController
|
||||
|
||||
return is_string($value) ? trim($value) : '';
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user