File tree Expand file tree Collapse file tree 2 files changed +18
-2
lines changed
Expand file tree Collapse file tree 2 files changed +18
-2
lines changed Original file line number Diff line number Diff line change 33declare (strict_types=1 );
44
55return [
6-
76 /*
87 |--------------------------------------------------------------------------
98 | Cross-Origin Resource Sharing (CORS) Configuration
3231 'max_age ' => 0 ,
3332
3433 'supports_credentials ' => false ,
35-
3634];
Original file line number Diff line number Diff line change 77use Closure ;
88use Hyperf \Context \ApplicationContext ;
99use Hyperf \Database \Model \Model ;
10+ use Hyperf \HttpServer \Request ;
11+ use Hyperf \HttpServer \Router \Dispatched ;
1012use Hyperf \HttpServer \Router \DispatcherFactory ;
1113use Hyperf \HttpServer \Router \RouteCollector ;
1214use RuntimeException ;
@@ -109,6 +111,22 @@ public function getExplicitBinding(string $param): ?Closure
109111 return $ this ->explicitBindings [$ param ] ?? null ;
110112 }
111113
114+ public function current (): ?Dispatched
115+ {
116+ return ApplicationContext::getContainer ()
117+ ->get (Request::class)
118+ ->getAttribute (Dispatched::class);
119+ }
120+
121+ public function currentRouteName (): ?string
122+ {
123+ if (! $ handler = $ this ->current ()->handler ?? null ) {
124+ return null ;
125+ }
126+
127+ return $ handler ->options ['as ' ] ?? null ;
128+ }
129+
112130 public static function __callStatic (string $ name , array $ arguments )
113131 {
114132 return ApplicationContext::getContainer ()
You can’t perform that action at this time.
0 commit comments