1
|
|
|
<?php namespace Arcanedev\Localization\Traits; |
2
|
|
|
|
3
|
|
|
/** |
4
|
|
|
* Class LocalizationKernelTrait |
5
|
|
|
* |
6
|
|
|
* @package Arcanedev\Localization\Traits |
7
|
|
|
* @author ARCANEDEV <[email protected]> |
8
|
|
|
* |
9
|
|
|
* @property \Illuminate\Foundation\Application app |
10
|
|
|
* @property \Arcanedev\Localization\Routing\Router router |
11
|
|
|
* @property array middlewareGroups |
12
|
|
|
* @property array routeMiddleware |
13
|
|
|
*/ |
14
|
|
|
trait LocalizationKernelTrait |
15
|
|
|
{ |
16
|
|
|
/* ------------------------------------------------------------------------------------------------ |
17
|
|
|
| Main Functions |
18
|
|
|
| ------------------------------------------------------------------------------------------------ |
19
|
|
|
*/ |
20
|
|
|
/** |
21
|
|
|
* Get the route dispatcher callback. |
22
|
|
|
* |
23
|
|
|
* @return \Closure |
24
|
|
|
*/ |
25
|
60 |
|
protected function dispatchToRouter() |
26
|
|
|
{ |
27
|
60 |
|
$this->router = $this->app['router']; |
28
|
|
|
|
29
|
60 |
|
$this->registerMiddlewareGroups(); |
30
|
60 |
|
$this->registerMiddleware(); |
31
|
|
|
|
32
|
60 |
|
return parent::dispatchToRouter(); |
33
|
|
|
} |
34
|
|
|
|
35
|
|
|
/* ------------------------------------------------------------------------------------------------ |
36
|
|
|
| Middleware Functions |
37
|
|
|
| ------------------------------------------------------------------------------------------------ |
38
|
|
|
*/ |
39
|
|
|
/** |
40
|
|
|
* Register middleware groups to router (since Laravel 5.2) |
41
|
|
|
*/ |
42
|
60 |
|
protected function registerMiddlewareGroups() |
43
|
|
|
{ |
44
|
60 |
|
if (property_exists($this, 'middlewareGroups')) { |
45
|
20 |
|
foreach ($this->middlewareGroups as $key => $middleware) { |
46
|
20 |
|
$this->router->middlewareGroup($key, $middleware); |
47
|
15 |
|
} |
48
|
15 |
|
} |
49
|
60 |
|
} |
50
|
|
|
|
51
|
|
|
/** |
52
|
|
|
* Register middleware to router |
53
|
|
|
*/ |
54
|
60 |
|
protected function registerMiddleware() |
55
|
|
|
{ |
56
|
60 |
|
foreach ($this->routeMiddleware as $key => $middleware) { |
57
|
60 |
|
$this->router->middleware($key, $middleware); |
58
|
45 |
|
} |
59
|
60 |
|
} |
60
|
|
|
} |
61
|
|
|
|