From 4d4467d4e6a3e9120545750f5d6358c6d812fd75 Mon Sep 17 00:00:00 2001 From: wangyi Date: Fri, 6 Sep 2019 20:04:37 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=F0=9F=90=9B=20ValidationMiddleware?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 继承自CoreMiddleware --- .../src/Middleware/ValidationMiddleware.php | 27 +++++-------------- 1 file changed, 7 insertions(+), 20 deletions(-) diff --git a/src/validation/src/Middleware/ValidationMiddleware.php b/src/validation/src/Middleware/ValidationMiddleware.php index bbba6a0d4..bc4ec539a 100644 --- a/src/validation/src/Middleware/ValidationMiddleware.php +++ b/src/validation/src/Middleware/ValidationMiddleware.php @@ -12,14 +12,11 @@ declare(strict_types=1); namespace Hyperf\Validation\Middleware; +use Hyperf\HttpServer\CoreMiddleware; use Hyperf\Validation\Contracts\Validation\ValidatesWhenResolved; use Psr\Container\ContainerInterface; -use Psr\Http\Message\ResponseInterface; -use Psr\Http\Message\ServerRequestInterface; -use Psr\Http\Server\MiddlewareInterface; -use Psr\Http\Server\RequestHandlerInterface; -class ValidationMiddleware implements MiddlewareInterface +class ValidationMiddleware extends CoreMiddleware { /** * @var ContainerInterface @@ -31,26 +28,16 @@ class ValidationMiddleware implements MiddlewareInterface parent::__construct($container, 'http'); } - public function process(ServerRequestInterface $request, RequestHandlerInterface $handler): ResponseInterface + public function parseParameters(string $controller, string $action, array $arguments): array { - $params = $request->get(Dispatched); + $params = parent::parseParameters($controller, $action, $arguments); + foreach ($params as $param) { if ($param instanceof ValidatesWhenResolved) { $param->validateResolved(); } } + + return $params; } -// -// public function parseParameters(string $controller, string $action, array $arguments): array -// { -// $params = parent::parseParameters($controller, $action, $arguments); -// -// foreach ($params as $param) { -// if ($param instanceof ValidatesWhenResolved) { -// $param->validateResolved(); -// } -// } -// -// return $params; -// } }