|
6 | 6 |
|
7 | 7 | use Closure;
|
8 | 8 | use Illuminate\Support\Facades\Route as BaseRoute;
|
| 9 | +use LaravelLang\Config\Facades\Config; |
9 | 10 | use LaravelLang\Routes\Concerns\RouteParameters;
|
10 | 11 | use LaravelLang\Routes\Helpers\Route as RouteName;
|
11 |
| -use LaravelLang\Routes\Middlewares\LocalizationByCookie; |
12 |
| -use LaravelLang\Routes\Middlewares\LocalizationByHeader; |
13 |
| -use LaravelLang\Routes\Middlewares\LocalizationByModel; |
14 |
| -use LaravelLang\Routes\Middlewares\LocalizationByParameterPrefix; |
15 |
| -use LaravelLang\Routes\Middlewares\LocalizationBySession; |
16 | 12 |
|
17 | 13 | class Route
|
18 | 14 | {
|
19 | 15 | use RouteParameters;
|
20 | 16 |
|
21 | 17 | public function group(Closure $callback): void
|
22 | 18 | {
|
23 |
| - BaseRoute::middleware([ |
24 |
| - LocalizationByCookie::class, |
25 |
| - LocalizationByHeader::class, |
26 |
| - LocalizationBySession::class, |
27 |
| - LocalizationByModel::class, |
28 |
| - ])->group($callback); |
| 19 | + $this->defaultGroup($callback); |
| 20 | + $this->prefixedGroup($callback); |
| 21 | + } |
29 | 22 |
|
| 23 | + protected function defaultGroup(Closure $callback): void |
| 24 | + { |
| 25 | + BaseRoute::middleware( |
| 26 | + Config::shared()->routes->group->middleware->default |
| 27 | + )->group($callback); |
| 28 | + } |
| 29 | + |
| 30 | + protected function prefixedGroup(Closure $callback): void |
| 31 | + { |
30 | 32 | BaseRoute::prefix('{' . $this->names()->parameter . '}')
|
31 | 33 | ->name(RouteName::prefix())
|
32 |
| - ->middleware([ |
33 |
| - LocalizationByParameterPrefix::class, |
34 |
| - LocalizationByCookie::class, |
35 |
| - LocalizationByHeader::class, |
36 |
| - LocalizationBySession::class, |
37 |
| - LocalizationByModel::class, |
38 |
| - ])->group($callback); |
| 34 | + ->middleware( |
| 35 | + Config::shared()->routes->group->middleware->prefix |
| 36 | + )->group($callback); |
39 | 37 | }
|
40 | 38 | }
|
0 commit comments