1
|
|
|
<?php namespace Arcanedev\Localization\Providers; |
2
|
|
|
|
3
|
|
|
use Arcanedev\Localization\Middleware; |
4
|
|
|
use Arcanedev\Support\Providers\RouteServiceProvider as ServiceProvider; |
5
|
|
|
use Arcanedev\Localization\Routing\Router; |
6
|
|
|
|
7
|
|
|
/** |
8
|
|
|
* Class RoutingServiceProvider |
9
|
|
|
* |
10
|
|
|
* @package Arcanedev\Localization\Providers |
11
|
|
|
* @author ARCANEDEV <[email protected]> |
12
|
|
|
*/ |
13
|
|
|
class RoutingServiceProvider extends ServiceProvider |
14
|
|
|
{ |
15
|
|
|
/* ----------------------------------------------------------------- |
16
|
|
|
| Properties |
17
|
|
|
| ----------------------------------------------------------------- |
18
|
|
|
*/ |
19
|
|
|
/** |
20
|
|
|
* The application's route middleware. |
21
|
|
|
* |
22
|
|
|
* These middleware may be assigned to groups or used individually. |
23
|
|
|
* |
24
|
|
|
* @var array |
25
|
|
|
*/ |
26
|
|
|
protected $routeMiddleware = [ |
27
|
|
|
'localization-session-redirect' => Middleware\LocaleSessionRedirect::class, |
28
|
|
|
'localization-cookie-redirect' => Middleware\LocaleCookieRedirect::class, |
29
|
|
|
'localization-redirect' => Middleware\LocalizationRedirect::class, |
30
|
|
|
'localized-routes' => Middleware\LocalizationRoutes::class, |
31
|
|
|
'translation-redirect' => Middleware\TranslationRedirect::class, |
32
|
|
|
]; |
33
|
|
|
|
34
|
|
|
/* ------------------------------------------------------------------------------------------------ |
35
|
|
|
| Main Functions |
36
|
|
|
| ------------------------------------------------------------------------------------------------ |
37
|
|
|
*/ |
38
|
|
|
/** |
39
|
|
|
* Register the service provider. |
40
|
|
|
*/ |
41
|
192 |
|
public function register() |
42
|
|
|
{ |
43
|
192 |
|
$this->registerRouter(); |
44
|
|
|
|
45
|
192 |
|
parent::register(); |
46
|
192 |
|
} |
47
|
|
|
|
48
|
|
|
/* ------------------------------------------------------------------------------------------------ |
49
|
|
|
| Router Functions |
50
|
|
|
| ------------------------------------------------------------------------------------------------ |
51
|
|
|
*/ |
52
|
|
|
/** |
53
|
|
|
* Register the router instance. |
54
|
|
|
*/ |
55
|
|
|
protected function registerRouter() |
56
|
|
|
{ |
57
|
192 |
|
$this->app->singleton('router', function ($app) { |
58
|
192 |
|
return new Router($app['events'], $app); |
59
|
192 |
|
}); |
60
|
192 |
|
} |
61
|
|
|
} |
62
|
|
|
|