Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
75.00% |
9 / 12 |
|
0.00% |
0 / 1 |
CRAP | |
0.00% |
0 / 1 |
| ViewServiceProvider | |
75.00% |
9 / 12 |
|
0.00% |
0 / 1 |
6.56 | |
0.00% |
0 / 1 |
| boot | |
75.00% |
9 / 12 |
|
0.00% |
0 / 1 |
6.56 | |||
| 1 | <?php |
| 2 | |
| 3 | namespace App\Providers; |
| 4 | |
| 5 | use Illuminate\Pagination\Paginator; |
| 6 | use Illuminate\Support\Facades\Cache; |
| 7 | use Illuminate\Support\Facades\File; |
| 8 | use Illuminate\Support\Facades\View; |
| 9 | use Illuminate\Support\ServiceProvider; |
| 10 | |
| 11 | class ViewServiceProvider extends ServiceProvider |
| 12 | { |
| 13 | /** |
| 14 | * Bootstrap any application services. |
| 15 | * |
| 16 | * @return void |
| 17 | */ |
| 18 | public function boot(): void |
| 19 | { |
| 20 | $appInfos = Cache::remember('composer', 360, function () { |
| 21 | return json_decode(File::get(\app_path('../composer.json'))); |
| 22 | }); |
| 23 | // Share composer.json infos. |
| 24 | if (isset($appInfos->name) and isset($appInfos->version) and isset($appInfos->license)) { |
| 25 | View::share('cpsr_name', $appInfos->name); |
| 26 | View::share('cpsr_version', $appInfos->version); |
| 27 | View::share('cpsr_license', $appInfos->license); |
| 28 | View::share('cpsr_support', $appInfos->support->email); |
| 29 | } |
| 30 | |
| 31 | if (!app()->runningInConsole()) { |
| 32 | // * FORCE BOOTSTRAP PAGINATOR (or custom if in front) |
| 33 | // Early boot, request wont be filled as expected. |
| 34 | if (collect(explode('/', \request()->getPathInfo()))->get(1) === 'bo') { |
| 35 | Paginator::defaultView('bo.modules.pagination'); |
| 36 | } else { |
| 37 | Paginator::useBootstrapFive(); |
| 38 | } |
| 39 | } |
| 40 | } |
| 41 | } |