-
Notifications
You must be signed in to change notification settings - Fork 9
/
Copy pathRoutingServiceProvider.php
51 lines (41 loc) · 1.22 KB
/
RoutingServiceProvider.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
<?php
namespace Cyd293\BackendSkin;
use Cyd293\BackendSkin\Router\UrlGenerator;
use October\Rain\Html\UrlServiceProvider;
class RoutingServiceProvider extends UrlServiceProvider
{
public function register()
{
$this->registerUrlGenerator();
parent::register();
}
protected function registerUrlGenerator()
{
$this->app->extend('url', function ($service, $app) {
$routes = $app['router']->getRoutes();
$url = new UrlGenerator(
$routes,
$app->rebinding(
'request',
$this->requestRebinder()
)
);
$url->setSessionResolver(function () {
return $this->app['session'] ?? null;
});
$url->setKeyResolver(function () {
return $this->app->make('config')->get('app.key');
});
$app->rebinding('routes', function ($app, $routes) {
$app['url']->setRoutes($routes);
});
return $url;
});
}
protected function requestRebinder()
{
return function ($app, $request) {
$app['url']->setRequest($request);
};
}
}