File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -68,11 +68,11 @@ public function run(Application\Request $request)
6868 }
6969
7070 $ params = $ request ->getParameters ();
71- if (!isset ($ params ['callback ' ])) {
72- throw new Application \BadRequestException ('Parameter callback is missing. ' );
71+ $ callback = isset ($ params ['callback ' ]) ? $ params ['callback ' ] : null ;
72+ if (!$ callback instanceof \Closure) {
73+ throw new Application \BadRequestException ('Parameter callback is not a valid closure. ' );
7374 }
74- $ callback = $ params ['callback ' ];
75- $ reflection = Nette \Utils \Callback::toReflection (Nette \Utils \Callback::check ($ callback ));
75+ $ reflection = new \ReflectionFunction ($ callback );
7676
7777 if ($ this ->context ) {
7878 foreach ($ reflection ->getParameters () as $ param ) {
Original file line number Diff line number Diff line change @@ -11,15 +11,6 @@ use Tester\Assert;
1111require __DIR__ . '/../bootstrap.php ' ;
1212
1313
14- class Invokable
15- {
16- public function __invoke ($ page , $ id , NetteModule \MicroPresenter $ presenter )
17- {
18- $ this ->log [] = 'Callback id ' . $ id . ' page ' . $ page ;
19- }
20- }
21-
22-
2314test (function () {
2415 $ presenter = $ p = new NetteModule \MicroPresenter ;
2516
@@ -37,21 +28,6 @@ test(function () {
3728});
3829
3930
40- test (function () {
41- $ presenter = new NetteModule \MicroPresenter ;
42-
43- $ presenter ->run (new Request ('Nette:Micro ' , 'GET ' , [
44- 'callback ' => $ invokable = new Invokable ,
45- 'id ' => 1 ,
46- 'page ' => 2 ,
47- ]));
48- Assert::same ([
49- 'Callback id 1 page 2 ' ,
50- ], $ invokable ->log );
51- });
52-
53-
54-
5531test (function () {
5632 $ container = Mockery::mock (Nette \DI \Container::class)
5733 ->shouldReceive ('getByType ' )->with ('stdClass ' , false )->once ()->andReturn (new stdClass )
You can’t perform that action at this time.
0 commit comments