diff --git a/system/src/Grav/Framework/Flex/FlexForm.php b/system/src/Grav/Framework/Flex/FlexForm.php index 879db72b6..2edfb1e4b 100644 --- a/system/src/Grav/Framework/Flex/FlexForm.php +++ b/system/src/Grav/Framework/Flex/FlexForm.php @@ -325,10 +325,7 @@ class FlexForm implements FlexFormInterface return $this; } - /** - * @return $this - */ - public function reset(): FlexFormInterface + public function reset(): void { $this->data = null; $this->files = []; @@ -339,8 +336,6 @@ class FlexForm implements FlexFormInterface $flash = $this->getFlash(); $flash->delete(); $this->flash = null; - - return $this; } /** diff --git a/system/src/Grav/Framework/Flex/Interfaces/FlexFormInterface.php b/system/src/Grav/Framework/Flex/Interfaces/FlexFormInterface.php index dedf059dc..5efac9d12 100644 --- a/system/src/Grav/Framework/Flex/Interfaces/FlexFormInterface.php +++ b/system/src/Grav/Framework/Flex/Interfaces/FlexFormInterface.php @@ -9,8 +9,7 @@ namespace Grav\Framework\Flex\Interfaces; -use Grav\Common\Data\Blueprint; -use Grav\Common\Data\Data; +use Grav\Framework\Form\Interfaces\FormInterface; use Grav\Framework\Route\Route; use Psr\Http\Message\ServerRequestInterface; use Psr\Http\Message\UploadedFileInterface; @@ -19,81 +18,8 @@ use Psr\Http\Message\UploadedFileInterface; * Class FlexForm * @package Grav\Framework\Flex */ -interface FlexFormInterface extends \Serializable +interface FlexFormInterface extends \Serializable, FormInterface { - /** - * @return string - */ - public function getId(): string; - - /** - * @param string $id - */ - public function setId(string $id): void; - - /** - * @return string - */ - public function getUniqueId(): string; - - /** - * @param string $uniqueId - */ - public function setUniqueId(string $uniqueId): void; - - /** - * @return string - */ - public function getName(): string; - - - /** - * @return string - */ - public function getNonceName(): string; - - /** - * @return string - */ - public function getNonceAction(): string; - - /** - * @return string - */ - public function getAction(): string; - - /** - * @return Data|FlexObjectInterface - */ - public function getData(); - - /** - * Get a value from the form. - * - * Note: Used in form fields. - * - * @param string $name - * @return mixed - */ - public function getValue(string $name); - - /** - * @return UploadedFileInterface[] - */ - public function getFiles() : array; - - /** - * @return Route|null - */ - public function getFileUploadAjaxRoute(): ?Route; - - /** - * @param $field - * @param $filename - * @return Route|null - */ - public function getFileDeleteAjaxRoute($field, $filename): ?Route; - /** * @return FlexObjectInterface */ @@ -105,6 +31,13 @@ interface FlexFormInterface extends \Serializable */ public function handleRequest(ServerRequestInterface $request): self; + /** + * @param array $data + * @param UploadedFileInterface[] $files + * @return $this + */ + public function submit(array $data, array $files = null): self; + /** * @return bool */ @@ -120,30 +53,6 @@ interface FlexFormInterface extends \Serializable */ public function isSubmitted(): bool; - /** - * @param array $data - * @param UploadedFileInterface[] $files - * @return $this - */ - public function submit(array $data, array $files = null): self; - - /** - * @return $this - */ - public function reset(): self; - - /** - * Note: Used in form fields. - * - * @return array - */ - public function getFields(): array; - - /** - * @return Blueprint - */ - public function getBlueprint(): Blueprint; - /** * @return string */ @@ -153,4 +62,16 @@ interface FlexFormInterface extends \Serializable * @return string */ public function getMediaRoute(): string; + + /** + * @return Route|null + */ + public function getFileUploadAjaxRoute(): ?Route; + + /** + * @param $field + * @param $filename + * @return Route|null + */ + public function getFileDeleteAjaxRoute($field, $filename): ?Route; } diff --git a/system/src/Grav/Framework/Form/Interfaces/FormInterface.php b/system/src/Grav/Framework/Form/Interfaces/FormInterface.php new file mode 100644 index 000000000..3dcb89c17 --- /dev/null +++ b/system/src/Grav/Framework/Form/Interfaces/FormInterface.php @@ -0,0 +1,129 @@ +