From ae205d810b62dce5e3e11aef07358c11ded48c77 Mon Sep 17 00:00:00 2001 From: "David T. Sadler" Date: Tue, 26 Oct 2021 21:07:43 +0100 Subject: Implement old --- src/DTS/Bookmark.php | 6 +++--- src/DTS/Old.php | 30 ++++++++++++++++++++++++++++++ src/DTS/Session.php | 2 +- src/DTS/Validated.php | 6 +++--- src/DTS/Validator.php | 3 ++- src/templates/create.php | 13 +------------ src/templates/edit.php | 13 +------------ src/templates/form_fields.php | 12 ++++++++++++ 8 files changed, 53 insertions(+), 32 deletions(-) create mode 100644 src/DTS/Old.php create mode 100644 src/templates/form_fields.php (limited to 'src') diff --git a/src/DTS/Bookmark.php b/src/DTS/Bookmark.php index 543a552..da9afa9 100644 --- a/src/DTS/Bookmark.php +++ b/src/DTS/Bookmark.php @@ -8,11 +8,11 @@ class Bookmark { public string $id; - public string $url; + public string $url = ''; - public string $title; + public string $title = ''; - public string $tag; + public string $tag = ''; public string $addedAt; diff --git a/src/DTS/Old.php b/src/DTS/Old.php new file mode 100644 index 0000000..8545f8d --- /dev/null +++ b/src/DTS/Old.php @@ -0,0 +1,30 @@ +old[$field] = $request[$field]; + } + } + } + + public function get(string $key, mixed $default = null): mixed + { + return $this->old[$key] ?? $default; + } +} diff --git a/src/DTS/Session.php b/src/DTS/Session.php index e5da42f..445f31c 100644 --- a/src/DTS/Session.php +++ b/src/DTS/Session.php @@ -8,7 +8,7 @@ class Session { private static ?self $instance = null; - private array $session; + private array $session = []; public static function getInstance() { diff --git a/src/DTS/Validated.php b/src/DTS/Validated.php index 5df8af7..86c6f64 100644 --- a/src/DTS/Validated.php +++ b/src/DTS/Validated.php @@ -6,9 +6,9 @@ namespace DTS; class Validated { - public ?string $url; + public string $url = ''; - public ?string $title; + public string $title = ''; - public ?string $tag; + public string $tag = ''; } diff --git a/src/DTS/Validator.php b/src/DTS/Validator.php index 7629e3b..472b38f 100644 --- a/src/DTS/Validator.php +++ b/src/DTS/Validator.php @@ -13,7 +13,8 @@ class Validator public Validated $validated; - function __construct(array $request) { + function __construct(array $request) + { $this->errors = new Errors(); $this->validated = new Validated(); diff --git a/src/templates/create.php b/src/templates/create.php index 2769290..0124e03 100644 --- a/src/templates/create.php +++ b/src/templates/create.php @@ -8,18 +8,7 @@ Back
-
- has('url')) { ?> -

get('url')); ?>

- -
- has('title')) { ?> -

get('title')); ?>

- -
- has('tag')) { ?> -

get('tag')); ?>

- +
diff --git a/src/templates/edit.php b/src/templates/edit.php index c1b7bda..e77dd48 100644 --- a/src/templates/edit.php +++ b/src/templates/edit.php @@ -9,18 +9,7 @@ Back
-
- has('url')) { ?> -

get('url')); ?>

- -
- has('title')) { ?> -

get('title')); ?>

- -
- has('tag')) { ?> -

get('tag')); ?>

- +
diff --git a/src/templates/form_fields.php b/src/templates/form_fields.php new file mode 100644 index 0000000..cfacfda --- /dev/null +++ b/src/templates/form_fields.php @@ -0,0 +1,12 @@ +
+has('url')) { ?> +

get('url')); ?>

+ +
+has('title')) { ?> +

get('title')); ?>

+ +
+has('tag')) { ?> +

get('tag')); ?>

+ -- cgit v1.2.3-13-gbd6f