1 | <?php |
||
11 | class Router |
||
12 | { |
||
13 | protected $router; |
||
14 | protected $url; |
||
15 | protected $route; |
||
16 | |||
17 | 68 | public function __construct(IlluminateRouter $router, PrefixUrl $url, PrefixRoute $route) |
|
23 | |||
24 | 21 | public function get($uri, $action = []) |
|
28 | |||
29 | 3 | public function post($uri, $action = []) |
|
33 | |||
34 | 3 | public function put($uri, $action = []) |
|
38 | |||
39 | 3 | public function patch($uri, $action = []) |
|
43 | |||
44 | 3 | public function delete($uri, $action = []) |
|
48 | |||
49 | 3 | public function options($uri, $action = []) |
|
53 | |||
54 | 36 | public function makeRoute($method, $uri, $action = []) |
|
62 | |||
63 | 32 | public function addLocale(Route $route, $action = []) |
|
64 | { |
||
65 | 32 | $locale = $this->getActionLocale($route); |
|
66 | |||
67 | 32 | if (!$locale) { |
|
68 | 1 | return $route; |
|
69 | } |
||
70 | |||
71 | 31 | $route = $this->switchRouteLocale($locale, $route); |
|
72 | 31 | $route = $this->switchUrlLocale($locale, $route, $action); |
|
73 | |||
74 | 31 | $route->middleware($this->makeSetSessionLocale($locale)); |
|
75 | |||
76 | 31 | return $route; |
|
77 | } |
||
78 | |||
79 | 33 | public function getActionLocale(Route $route) |
|
85 | |||
86 | 35 | public function getActionLocales(Route $route) |
|
92 | |||
93 | 32 | public function switchRouteLocale($locale, Route $route) |
|
105 | |||
106 | 31 | public function setRouteName($name, Route $route) |
|
114 | |||
115 | 31 | public function switchUrlLocale($locale, Route $route, array $action = []) |
|
116 | { |
||
117 | 31 | $uri = $this->url->switchLocale($locale, $route->uri(), $action); |
|
118 | 31 | $route->setUri($uri); |
|
119 | |||
120 | 31 | return $route; |
|
121 | } |
||
122 | |||
123 | 31 | public function makeSetSessionLocale($locale) |
|
127 | |||
128 | 30 | public function refreshRoutes() |
|
135 | |||
136 | 5 | public function __call($method, $arguments) |
|
140 | } |
||
141 |