File tree Expand file tree Collapse file tree 2 files changed +41
-0
lines changed Expand file tree Collapse file tree 2 files changed +41
-0
lines changed Original file line number Diff line number Diff line change @@ -299,6 +299,16 @@ protected function parseControllerCallback()
299
299
return Str::parseCallback ($ this ->action ['uses ' ]);
300
300
}
301
301
302
+ /**
303
+ * Flush the cached container instance on the route.
304
+ *
305
+ * @return void
306
+ */
307
+ public function flushController ()
308
+ {
309
+ $ this ->controller = null ;
310
+ }
311
+
302
312
/**
303
313
* Determine if the route matches a given request.
304
314
*
Original file line number Diff line number Diff line change @@ -1763,6 +1763,25 @@ public function testResponseIsReturned()
1763
1763
$ this ->assertNotInstanceOf (JsonResponse::class, $ response );
1764
1764
}
1765
1765
1766
+ public function testRouteFlushController ()
1767
+ {
1768
+ $ container = new Container ;
1769
+ $ router = $ this ->getRouter ();
1770
+
1771
+ $ router ->get ('count ' , ActionCountStub::class);
1772
+ $ request = Request::create ('count ' , 'GET ' );
1773
+
1774
+ $ response = $ router ->dispatch ($ request );
1775
+ $ this ->assertSame (1 , (int ) $ response ->getContent ());
1776
+
1777
+ $ response = $ router ->dispatch ($ request );
1778
+ $ this ->assertSame (2 , (int ) $ response ->getContent ());
1779
+
1780
+ $ request ->route ()->flushController ();
1781
+ $ response = $ router ->dispatch ($ request );
1782
+ $ this ->assertSame (1 , (int ) $ response ->getContent ());
1783
+ }
1784
+
1766
1785
public function testJsonResponseIsReturned ()
1767
1786
{
1768
1787
$ router = $ this ->getRouter ();
@@ -2304,6 +2323,18 @@ public function __invoke()
2304
2323
}
2305
2324
}
2306
2325
2326
+ class ActionCountStub
2327
+ {
2328
+ protected $ count = 0 ;
2329
+
2330
+ public function __invoke ()
2331
+ {
2332
+ $ this ->count ++;
2333
+
2334
+ return $ this ->count ;
2335
+ }
2336
+ }
2337
+
2307
2338
interface ExampleMiddlewareContract
2308
2339
{
2309
2340
//
You can’t perform that action at this time.
0 commit comments