Skip to content

Commit 74c2acd

Browse files
committed
Fixing ConditionMiddleware,
addning requesthandler capability to MiddlewarePipe
1 parent e33191a commit 74c2acd

File tree

2 files changed

+23
-4
lines changed

2 files changed

+23
-4
lines changed

src/Mouf/Mvc/Splash/ConditionMiddleware.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,11 +43,11 @@ public function __construct(ToCondition $condition, MiddlewareInterface $ifMiddl
4343
public function process(ServerRequestInterface $request, RequestHandlerInterface $handler): ResponseInterface
4444
{
4545
if($this->condition->isOk()) {
46-
$this->ifMiddleware->process($request, $handler);
46+
return $this->ifMiddleware->process($request, $handler);
4747
} else if($this->elseMiddleware) {
48-
$this->elseMiddleware->process($request, $handler);
48+
return $this->elseMiddleware->process($request, $handler);
4949
} else {
50-
$handler->handle($request);
50+
return $handler->handle($request);
5151
}
5252
}
5353
}

src/Mouf/Mvc/Splash/MiddlewarePipe.php

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
* Check out the Splash documentation here:
2222
* <a href="https://github.com/thecodingmachine/mvc.splash/">https://github.com/thecodingmachine/mvc.splash/</a>.
2323
*/
24-
class MiddlewarePipe implements MiddlewareInterface
24+
class MiddlewarePipe implements MiddlewareInterface, RequestHandlerInterface
2525
{
2626
private $zendPipe;
2727

@@ -47,5 +47,24 @@ public function process(ServerRequestInterface $request, RequestHandlerInterface
4747
return $this->zendPipe->process($request, $handler);
4848
}
4949

50+
/**
51+
* Handle an incoming request.
52+
*
53+
* Attempts to handle an incoming request by doing the following:
54+
*
55+
* - Cloning itself, to produce a request handler.
56+
* - Dequeuing the first middleware in the cloned handler.
57+
* - Processing the first middleware using the request and the cloned handler.
58+
*
59+
* If the pipeline is empty at the time this method is invoked, it will
60+
* raise an exception.
61+
*
62+
* @throws Exception\EmptyPipelineException if no middleware is present in
63+
* the instance in order to process the request.
64+
*/
65+
public function handle(ServerRequestInterface $request) : ResponseInterface
66+
{
67+
return $this->zendPipe->handle($request);
68+
}
5069

5170
}

0 commit comments

Comments
 (0)