1 | <?php |
||
21 | class MultiLangServiceProvider extends ServiceProvider |
||
22 | { |
||
23 | /** |
||
24 | * Indicates if loading of the provider is deferred. |
||
25 | * |
||
26 | * @var bool |
||
27 | */ |
||
28 | protected $defer = false; |
||
29 | |||
30 | /** |
||
31 | * Bootstrap any application services. |
||
32 | * |
||
33 | * @return void |
||
34 | */ |
||
35 | 41 | public function boot() |
|
36 | { |
||
37 | // Publish config files |
||
38 | 41 | $this->publishes( |
|
39 | [ |
||
40 | 41 | __DIR__ . '/../config/config.php' => config_path('multilang.php'), |
|
41 | 41 | __DIR__ . '/../views' => base_path('resources/views/vendor/multilang'), |
|
42 | ] |
||
43 | 41 | ); |
|
44 | |||
45 | // Append the country settings |
||
46 | 41 | $this->mergeConfigFrom( |
|
47 | 41 | __DIR__ . '/../config/config.php', |
|
48 | 'multilang' |
||
49 | 41 | ); |
|
50 | |||
51 | // Register blade directives |
||
52 | Blade::directive('t', function ($expression) { |
||
53 | return "<?php echo e(t({$expression})); ?>"; |
||
54 | 41 | }); |
|
55 | |||
56 | $this->app['events']->listen(RouteMatched::class, function () { |
||
57 | $scope = $this->app['config']->get('app.scope'); |
||
58 | if ($scope && $scope != 'global') { |
||
59 | $this->app['multilang']->setScope($scope); |
||
60 | } |
||
61 | $this->app['multilang']->setLocale($this->app->getLocale()); |
||
62 | 41 | }); |
|
63 | |||
64 | 41 | $this->loadViewsFrom(__DIR__ . '/../views', 'multilang'); |
|
65 | 41 | } |
|
66 | |||
67 | /** |
||
68 | * Register any application services. |
||
69 | * |
||
70 | * @return void |
||
71 | */ |
||
72 | 41 | public function register() |
|
136 | |||
137 | /** |
||
138 | * Get the services provided by the provider. |
||
139 | * |
||
140 | * @return array |
||
141 | */ |
||
142 | 3 | public function provides() |
|
153 | } |
||
154 |