From 6caf38f1e99e1722789a41d89cc4e7f7a8d0c66f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=90=91=E6=9E=97?= Date: Sun, 16 Apr 2023 14:46:08 +0800 Subject: [PATCH] =?UTF-8?q?=E5=8F=98=E6=9B=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/Inject/AbstractRequestMethod.php | 27 +-------------------------- 1 file changed, 1 insertion(+), 26 deletions(-) diff --git a/src/Inject/AbstractRequestMethod.php b/src/Inject/AbstractRequestMethod.php index ce9b14a..5f222af 100644 --- a/src/Inject/AbstractRequestMethod.php +++ b/src/Inject/AbstractRequestMethod.php @@ -15,9 +15,8 @@ abstract class AbstractRequestMethod /** * @param string $path - * @param string $formValidate */ - public function __construct(readonly public string $path, public string $formValidate = '') + public function __construct(readonly public string $path) { } @@ -41,30 +40,6 @@ abstract class AbstractRequestMethod $middlewareManager->set($class::class, $method, $instance->middleware); } - - if ($this->formValidate !== '') { - $middlewareManager->set($class::class, $method, ValidatorMiddleware::class, [$this->getFormRule()]); - } } - - /** - * @return Validator|null - * @throws ReflectionException - */ - public function getFormRule(): ?Validator - { - $validator = new Validator(); - $reflect = \Kiri::getDi()->getReflectionClass($this->formValidate); - $model = $reflect->newInstanceWithoutConstructor(); - foreach ($reflect->getProperties() as $property) { - foreach ($property->getAttributes() as $attribute) { - $rule = $attribute->newInstance(); - if ($rule instanceof ValidatorInterface) { - $validator->addRule($property->getName(), $model, $rule); - } - } - } - return $validator; - } }