From 9dc44dcfa82e438f53202b1ee255815f57868253 Mon Sep 17 00:00:00 2001 From: Robert Sesek Date: Sat, 3 Dec 2016 23:56:40 -0500 Subject: [PATCH] Middleware no longer takes a Pipeline. --- http2/action.php | 2 +- http2/middleware.php | 10 +++------- http2/pipeline.php | 6 +++--- http2/router.php | 5 ++--- 4 files changed, 9 insertions(+), 14 deletions(-) diff --git a/http2/action.php b/http2/action.php index 68a8788..4b14e53 100644 --- a/http2/action.php +++ b/http2/action.php @@ -41,7 +41,7 @@ class Action extends Middleware { return $this->defaultRequest($request); } - $response = $this->{$action}(); + $response = $this->{$action}($request); $this->afterRequest($response); diff --git a/http2/middleware.php b/http2/middleware.php index 4e51841..c393d46 100644 --- a/http2/middleware.php +++ b/http2/middleware.php @@ -21,12 +21,9 @@ require_once HOPLITE_ROOT . '/http2/request.php'; require_once HOPLITE_ROOT . '/http2/response.php'; abstract class Middleware { - protected $pipeline; protected $next; - public function __construct(Pipeline $pipeline, - Middleware $next) { - $this->pipeline = $pipeline; + public function __construct(Middleware $next) { $this->next = $next; } @@ -48,10 +45,9 @@ class Sentinel extends Middleware { class ClosureMiddleware extends Middleware { private $closure; - public function __construct(Pipeline $pipeline, - Middleware $next, + public function __construct(Middleware $next, \Closure $closure) { - parent::__construct($pipeline, $next); + parent::__construct($next); $this->closure = $closure; } diff --git a/http2/pipeline.php b/http2/pipeline.php index 96c1e2f..ffd0154 100644 --- a/http2/pipeline.php +++ b/http2/pipeline.php @@ -40,15 +40,15 @@ class Pipeline { public function buildMiddleware($args, $next) { if ($args instanceof \Closure) { - return new ClosureMiddleware($this, $next, $args); + return new ClosureMiddleware($next, $args); } else if ($args instanceof Pipeline) { return $args->_build($next); } else if (is_array($args)) { $class = array_shift($args); - array_unshift($args, $this, $next); + array_unshift($args, $next); return new $class(...$args); } else { - return new $args($this, $next); + return new $args($next); } } diff --git a/http2/router.php b/http2/router.php index d991add..352a8b2 100644 --- a/http2/router.php +++ b/http2/router.php @@ -35,11 +35,10 @@ class Router extends Middleware { private $map; private $subpipe; - public function __construct(Pipeline $pipeline, - Middleware $next, + public function __construct(Middleware $next, RouteMap $map, Pipeline $subpipe=NULL) { - parent::__construct($pipeline, $next); + parent::__construct($next); $this->map = $map; $this->subpipe = $subpipe ? $subpipe : new Pipeline(); } -- 2.43.5