Skip to content

Commit f25dc52

Browse files
committed
fix: fix php-cs
1 parent 15b96aa commit f25dc52

File tree

2 files changed

+18
-2
lines changed

2 files changed

+18
-2
lines changed

src/http/publish/cors.php

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
declare(strict_types=1);
44

55
return [
6-
76
/*
87
|--------------------------------------------------------------------------
98
| Cross-Origin Resource Sharing (CORS) Configuration
@@ -32,5 +31,4 @@
3231
'max_age' => 0,
3332

3433
'supports_credentials' => false,
35-
3634
];

src/router/src/Router.php

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@
77
use Closure;
88
use Hyperf\Context\ApplicationContext;
99
use Hyperf\Database\Model\Model;
10+
use Hyperf\HttpServer\Request;
11+
use Hyperf\HttpServer\Router\Dispatched;
1012
use Hyperf\HttpServer\Router\DispatcherFactory;
1113
use Hyperf\HttpServer\Router\RouteCollector;
1214
use 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()

0 commit comments

Comments
 (0)