|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace Nikaia\TranslationSheet; |
|
4
|
|
|
|
|
5
|
|
|
use Illuminate\Support\ServiceProvider; |
|
6
|
|
|
use Nikaia\TranslationSheet\Client\Client; |
|
7
|
|
|
use Nikaia\TranslationSheet\Commands\Lock; |
|
8
|
|
|
use Nikaia\TranslationSheet\Commands\Open; |
|
9
|
|
|
use Nikaia\TranslationSheet\Commands\Prepare; |
|
10
|
|
|
use Nikaia\TranslationSheet\Commands\Publish; |
|
11
|
|
|
use Nikaia\TranslationSheet\Commands\Pull; |
|
12
|
|
|
use Nikaia\TranslationSheet\Commands\Push; |
|
13
|
|
|
use Nikaia\TranslationSheet\Commands\Setup; |
|
14
|
|
|
use Nikaia\TranslationSheet\Commands\Status; |
|
15
|
|
|
use Nikaia\TranslationSheet\Commands\Unlock; |
|
16
|
|
|
|
|
17
|
|
|
class TranslationSheetServiceProvider extends ServiceProvider |
|
18
|
38 |
|
{ |
|
19
|
|
|
public function boot() |
|
20
|
38 |
|
{ |
|
21
|
38 |
|
$this->publishes([ |
|
22
|
38 |
|
__DIR__.'/../config/config.php' => config_path('translation_sheet.php'), |
|
23
|
38 |
|
], 'config'); |
|
24
|
|
|
} |
|
25
|
38 |
|
|
|
26
|
|
|
public function register() |
|
27
|
38 |
|
{ |
|
28
|
|
|
$this->mergeConfigFrom(__DIR__.'/../config/config.php', 'translation_sheet'); |
|
29
|
38 |
|
|
|
30
|
|
|
$this->registerGoogleApiClient(); |
|
31
|
38 |
|
|
|
32
|
|
|
$this->registerSpreadsheet(); |
|
33
|
38 |
|
|
|
34
|
38 |
|
$this->registerCommands(); |
|
35
|
|
|
} |
|
36
|
38 |
|
|
|
37
|
|
|
private function registerGoogleApiClient() |
|
38
|
|
|
{ |
|
39
|
20 |
|
$this->app->singleton(Client::class, function () { |
|
40
|
20 |
|
return Client::create( |
|
41
|
20 |
|
$this->app['config']['translation_sheet.serviceAccountCredentialsFile'], |
|
42
|
|
|
$this->app['config']['translation_sheet.googleApplicationName'] |
|
43
|
38 |
|
); |
|
44
|
38 |
|
}); |
|
45
|
|
|
} |
|
46
|
38 |
|
|
|
47
|
|
|
private function registerSpreadsheet() |
|
48
|
|
|
{ |
|
49
|
3 |
|
$this->app->singleton(Spreadsheet::class, function () { |
|
50
|
3 |
|
return new Spreadsheet( |
|
51
|
3 |
|
$this->app['config']['translation_sheet.spreadsheetId'], |
|
52
|
|
|
Util::asArray($this->app['config']['translation_sheet.locales']) |
|
53
|
38 |
|
); |
|
54
|
38 |
|
}); |
|
55
|
|
|
} |
|
56
|
38 |
|
|
|
57
|
|
|
private function registerCommands() |
|
58
|
38 |
|
{ |
|
59
|
38 |
|
$this->commands([ |
|
60
|
|
|
Setup::class, |
|
61
|
|
|
Push::class, |
|
62
|
|
|
Pull::class, |
|
63
|
|
|
Prepare::class, |
|
64
|
|
|
Lock::class, |
|
65
|
|
|
Unlock::class, |
|
66
|
|
|
Status::class, |
|
67
|
|
|
Open::class, |
|
68
|
38 |
|
Publish::class, |
|
69
|
|
|
]); |
|
70
|
|
|
} |
|
71
|
|
|
} |
|
72
|
|
|
|