1 | <?php |
||
10 | class LocaleServiceProvider extends ServiceProvider |
||
11 | { |
||
12 | 81 | public function register() |
|
13 | { |
||
14 | 81 | require_once __DIR__.'/helpers.php'; |
|
15 | |||
16 | 81 | $this->publishes([ |
|
17 | 81 | __DIR__.'/config/locale.php' => config_path('thinktomorrow/locale.php'), |
|
18 | ]); |
||
19 | |||
20 | 81 | $this->mergeConfigFrom( |
|
21 | 81 | __DIR__.'/config/locale.php', |
|
22 | 81 | 'thinktomorrow.locale' |
|
23 | ); |
||
24 | |||
25 | 81 | $config = Config::from($this->getConfigValues()); |
|
26 | |||
27 | $this->app->singleton(Detect::class, function ($app) use ($config) { |
||
28 | return new Detect($app['request'], $config); |
||
29 | 81 | }); |
|
30 | |||
31 | $this->app->singleton(UrlParser::class, function ($app) { |
||
32 | 74 | return new UrlParser( |
|
33 | 74 | $app['Illuminate\Contracts\Routing\UrlGenerator'] |
|
34 | ); |
||
35 | 81 | }); |
|
36 | |||
37 | $this->app->singleton(RouteParser::class, function ($app) { |
||
38 | 74 | return new RouteParser( |
|
39 | 74 | $app['Thinktomorrow\Locale\Parsers\UrlParser'], |
|
40 | 74 | $app['translator'] |
|
41 | ); |
||
42 | 81 | }); |
|
43 | |||
44 | $this->app->singleton(LocaleUrl::class, function ($app) use ($config) { |
||
45 | return new LocaleUrl( |
||
46 | $app['Thinktomorrow\Locale\Detect'], |
||
47 | $app['Thinktomorrow\Locale\Parsers\UrlParser'], |
||
48 | $app['Thinktomorrow\Locale\Parsers\RouteParser'], |
||
49 | $config |
||
50 | ); |
||
51 | 81 | }); |
|
52 | |||
53 | /* |
||
54 | * Facade for getting current active scope |
||
55 | */ |
||
56 | $this->app->singleton('tt-locale-scope', function ($app) { |
||
57 | 10 | return $app->make(Detect::class)->detectLocale()->getScope(); |
|
58 | 81 | }); |
|
59 | 81 | } |
|
60 | |||
61 | 81 | private function getConfigValues() |
|
69 | } |
||
70 |