File tree Expand file tree Collapse file tree 2 files changed +28
-6
lines changed Expand file tree Collapse file tree 2 files changed +28
-6
lines changed Original file line number Diff line number Diff line change @@ -71,21 +71,18 @@ public function run(Application\Request $request)
7171 if (!isset ($ params ['callback ' ])) {
7272 throw new Application \BadRequestException ('Parameter callback is missing. ' );
7373 }
74- $ params ['presenter ' ] = $ this ;
7574 $ callback = $ params ['callback ' ];
7675 $ reflection = Nette \Utils \Callback::toReflection (Nette \Utils \Callback::check ($ callback ));
77- $ params = Application \UI \ComponentReflection::combineArgs ($ reflection , $ params );
7876
7977 if ($ this ->context ) {
8078 foreach ($ reflection ->getParameters () as $ param ) {
8179 if ($ param ->getClass ()) {
82- unset( $ params [$ param ->getPosition ()]);
80+ $ params [$ param ->getName ()] = $ this -> context -> getByType ( $ param -> getClass ()-> getName (), FALSE );
8381 }
8482 }
85-
86- $ params = Nette \DI \Helpers::autowireArguments ($ reflection , $ params , $ this ->context );
87- $ params ['presenter ' ] = $ this ;
8883 }
84+ $ params ['presenter ' ] = $ this ;
85+ $ params = Application \UI \ComponentReflection::combineArgs ($ reflection , $ params );
8986
9087 $ response = call_user_func_array ($ callback , $ params );
9188
Original file line number Diff line number Diff line change @@ -49,3 +49,28 @@ test(function () {
4949 'Callback id 1 page 2 ' ,
5050 ], Notes::fetch ());
5151});
52+
53+
54+
55+ class MockContainer extends Nette \DI \Container
56+ {
57+ function getByType ($ class , $ need = TRUE )
58+ {
59+ Notes::add ("getByType( $ class) " );
60+ return new stdClass ;
61+ }
62+ }
63+
64+ test (function () {
65+ $ presenter = new NetteModule \MicroPresenter (new MockContainer );
66+
67+ $ presenter ->run (new Request ('Nette:Micro ' , 'GET ' , [
68+ 'callback ' => function (stdClass $ obj ) {
69+ Notes::add (get_class ($ obj ));
70+ },
71+ ]));
72+ Assert::same ([
73+ 'getByType(stdClass) ' ,
74+ 'stdClass ' ,
75+ ], Notes::fetch ());
76+ });
You can’t perform that action at this time.
0 commit comments