From 0d9db0470ee1a648c9d11cf475918f20eac0c95b Mon Sep 17 00:00:00 2001 From: Dave Mc Nicoll Date: Tue, 9 Mar 2021 15:27:54 +0000 Subject: [PATCH] - Worked with the files begin on the context part --- src/Form/UiFile.php | 10 +++++----- src/Method/FormContext.php | 15 +++++++++++++-- src/Method/FormHandler.php | 2 ++ src/Method/FormInterface.php | 2 +- 4 files changed, 21 insertions(+), 8 deletions(-) diff --git a/src/Form/UiFile.php b/src/Form/UiFile.php index 9a2bff0..7b45f7c 100644 --- a/src/Form/UiFile.php +++ b/src/Form/UiFile.php @@ -6,8 +6,8 @@ class UiFile extends UiInput { public string $token = "ui.file"; - public array $attributes = [ - 'class' => "ui-file", - 'type' => "file", - ]; -} + public array $attributes = [ + 'class' => "ui-file", + 'type' => "file", + ]; +} \ No newline at end of file diff --git a/src/Method/FormContext.php b/src/Method/FormContext.php index f4a0251..edd266a 100644 --- a/src/Method/FormContext.php +++ b/src/Method/FormContext.php @@ -10,9 +10,13 @@ class FormContext implements FormContextInterface public string $formName; public bool $formSent; - + + public bool $formExecuted = false; + public array $values = []; + public array $files = []; + public array $messages = []; public ServerRequestInterface $request; @@ -28,6 +32,8 @@ class FormContext implements FormContextInterface } $this->values = $request->getParsedBody() ?: []; + + $this->files = $request->getUploadedFiles() ?: []; } public function valid() : bool @@ -40,7 +46,12 @@ class FormContext implements FormContextInterface return true; } - + + public function executed() : bool + { + return $this->formExecuted; + } + public function formSent() : bool { return $this->formSent; diff --git a/src/Method/FormHandler.php b/src/Method/FormHandler.php index 223bb44..ba8bab7 100644 --- a/src/Method/FormHandler.php +++ b/src/Method/FormHandler.php @@ -50,6 +50,8 @@ class FormHandler { if ( $this->sent ) { if ( $this->form->validate($this->context) ) { $this->executionStatus = $this->form->execute($this->context); + + $this->context->formExecuted = true; } } } diff --git a/src/Method/FormInterface.php b/src/Method/FormInterface.php index 0471fc3..cbfb766 100644 --- a/src/Method/FormInterface.php +++ b/src/Method/FormInterface.php @@ -8,5 +8,5 @@ interface FormInterface public function validate(FormContextInterface $context) : bool; - public function execute(FormContextInterface $context) : void; + public function execute(FormContextInterface $context) /* : mixed */; } \ No newline at end of file