1 | <?php |
||
18 | class NotFoundRouter implements MiddlewareInterface |
||
19 | { |
||
20 | /** |
||
21 | * The logger. |
||
22 | * |
||
23 | * @var LoggerInterface |
||
24 | */ |
||
25 | private $log; |
||
26 | |||
27 | /** |
||
28 | * @var Http404HandlerInterface |
||
29 | */ |
||
30 | private $pageNotFoundController; |
||
31 | |||
32 | public function __construct(Http404HandlerInterface $pageNotFoundController, LoggerInterface $log = null) |
||
37 | |||
38 | /** |
||
39 | * Process an incoming request and/or response. |
||
40 | * |
||
41 | * Accepts a server-side request and a response instance, and does |
||
42 | * something with them. |
||
43 | * |
||
44 | * If the response is not complete and/or further processing would not |
||
45 | * interfere with the work done in the middleware, or if the middleware |
||
46 | * wants to delegate to another process, it can use the `$out` callable |
||
47 | * if present. |
||
48 | * |
||
49 | * If the middleware does not return a value, execution of the current |
||
50 | * request is considered complete, and the response instance provided will |
||
51 | * be considered the response to return. |
||
52 | * |
||
53 | * Alternately, the middleware may return a response instance. |
||
54 | * |
||
55 | * Often, middleware will `return $out();`, with the assumption that a |
||
56 | * later middleware will return a response. |
||
57 | * |
||
58 | * @param Request $request |
||
59 | * @param Response $response |
||
60 | * @param null|callable $out |
||
61 | * |
||
62 | * @return null|Response |
||
63 | */ |
||
64 | public function __invoke(Request $request, Response $response, callable $out = null) |
||
78 | } |
||
79 |