| Conditions | 2 |
| Paths | 2 |
| Total Lines | 21 |
| Code Lines | 11 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 0 |
| CRAP Score | 6 |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 12 | public function handle(Request $request, Closure $next) |
||
| 13 | { |
||
| 14 | $parameter = 'subdomain'; |
||
| 15 | $subdomain = $request->route()->parameter($parameter) ?? key(config('twill.app_names')); |
||
| 16 | |||
| 17 | // Set subdomain as default URL parameter to not have |
||
| 18 | // to add it manually when using route helpers |
||
| 19 | URL::defaults([$parameter => $subdomain]); |
||
| 20 | |||
| 21 | $blockLayout = View::exists($subdomain . '.layouts.block') ? ($subdomain . '.layouts.block') : 'site.layouts.blocks'; |
||
| 22 | |||
| 23 | config([ |
||
| 24 | 'app.name' => config('twill.app_names')[$subdomain] ?? config('app.name'), |
||
| 25 | 'twill-navigation' => config('twill-navigation')[$subdomain] ?? key(config('twill-navigation')), |
||
| 26 | 'twill.dashboard.modules' => config('twill.dashboard.modules')[$subdomain] ?? key(config('twill.dashboard.modules')), |
||
| 27 | 'twill.block_editor.block_single_layout' => $blockLayout, |
||
| 28 | ]); |
||
| 29 | |||
| 30 | $request->route()->forgetParameter($parameter); |
||
| 31 | |||
| 32 | return $next($request); |
||
| 33 | } |
||
| 35 |