File tree Expand file tree Collapse file tree 2 files changed +38
-5
lines changed Expand file tree Collapse file tree 2 files changed +38
-5
lines changed Original file line number Diff line number Diff line change @@ -39,7 +39,13 @@ public static function create(?ContainerInterface $container = null): App
3939 return $ app ;
4040 }
4141
42- private static function createControllerInvoker (ContainerInterface $ container ): ControllerInvoker
42+ /**
43+ * Create an invoker with the default resolvers.
44+ *
45+ * @param ContainerInterface $container
46+ * @return Invoker
47+ */
48+ protected static function createInvoker (ContainerInterface $ container ): Invoker
4349 {
4450 $ resolvers = [
4551 // Inject parameters by name first
@@ -50,8 +56,17 @@ private static function createControllerInvoker(ContainerInterface $container):
5056 new DefaultValueResolver ,
5157 ];
5258
53- $ invoker = new Invoker (new ResolverChain ($ resolvers ), $ container );
59+ return new Invoker (new ResolverChain ($ resolvers ), $ container );
60+ }
5461
55- return new ControllerInvoker ($ invoker );
62+ /**
63+ * Create a controller invoker with the default resolvers.
64+ *
65+ * @param ContainerInterface $container
66+ * @return ControllerInvoker
67+ */
68+ protected static function createControllerInvoker (ContainerInterface $ container ): ControllerInvoker
69+ {
70+ return new ControllerInvoker (self ::createInvoker ($ container ));
5671 }
5772}
Original file line number Diff line number Diff line change @@ -42,10 +42,28 @@ public function __invoke(
4242 // Inject the attributes defined on the request
4343 $ parameters += $ request ->getAttributes ();
4444
45- return $ this ->invoker ->call ($ callable , $ parameters );
45+ return $ this ->processResponse ( $ this -> invoker ->call ($ callable , $ parameters) );
4646 }
4747
48- private static function injectRouteArguments (ServerRequestInterface $ request , array $ routeArguments ): ServerRequestInterface
48+ /**
49+ * Allow for child classes to process the response.
50+ *
51+ * @param ResponseInterface|string The response from the callable.
52+ * @return ResponseInterface|string The processed response
53+ */
54+ protected function processResponse ($ response )
55+ {
56+ return $ response ;
57+ }
58+
59+ /**
60+ * Inject route arguments into the request.
61+ *
62+ * @param ServerRequestInterface $request
63+ * @param array $routeArguments
64+ * @return ServerRequestInterface
65+ */
66+ protected static function injectRouteArguments (ServerRequestInterface $ request , array $ routeArguments ): ServerRequestInterface
4967 {
5068 $ requestWithArgs = $ request ;
5169 foreach ($ routeArguments as $ key => $ value ) {
You can’t perform that action at this time.
0 commit comments