1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace CSlant\LaravelTelegramGitNotifier\Providers; |
4
|
|
|
|
5
|
|
|
use CSlant\LaravelTelegramGitNotifier\Commands\ChangeOwnerConfigJson; |
6
|
|
|
use CSlant\LaravelTelegramGitNotifier\Commands\SetWebhook; |
7
|
|
|
use Illuminate\Support\ServiceProvider; |
8
|
|
|
|
9
|
|
|
class TelegramGitNotifierServiceProvider extends ServiceProvider |
10
|
|
|
{ |
11
|
|
|
/** |
12
|
|
|
* Bootstrap services. |
13
|
|
|
* |
14
|
|
|
* @return void |
15
|
|
|
*/ |
16
|
|
|
public function boot(): void |
17
|
|
|
{ |
18
|
|
|
$routePath = __DIR__.'/../../routes/bot.php'; |
19
|
|
|
if (file_exists($routePath)) { |
20
|
|
|
$this->loadRoutesFrom($routePath); |
21
|
|
|
} |
22
|
|
|
|
23
|
|
|
$viewPath = __DIR__.'/../../resources/views'; |
24
|
|
|
if (file_exists($viewPath)) { |
25
|
|
|
$this->loadViewsFrom($viewPath, config('telegram-git-notifier.view.namespace')); |
26
|
|
|
} |
27
|
|
|
|
28
|
|
|
$this->loadTranslationsFrom(__DIR__.'/../../lang', 'tg-notifier'); |
29
|
|
|
|
30
|
|
|
$this->registerCommands(); |
31
|
|
|
|
32
|
|
|
$this->registerAssetPublishing(); |
33
|
|
|
} |
34
|
|
|
|
35
|
|
|
/** |
36
|
|
|
* Register services. |
37
|
|
|
* |
38
|
|
|
* @return void |
39
|
|
|
*/ |
40
|
|
|
public function register(): void |
41
|
|
|
{ |
42
|
|
|
$configPath = __DIR__.'/../../config/telegram-git-notifier.php'; |
43
|
|
|
$this->mergeConfigFrom($configPath, 'telegram-git-notifier'); |
44
|
|
|
} |
45
|
|
|
|
46
|
|
|
/** |
47
|
|
|
* Get the services provided by the provider. |
48
|
|
|
* |
49
|
|
|
* @return array<string>|null |
50
|
|
|
*/ |
51
|
|
|
public function provides(): ?array |
52
|
|
|
{ |
53
|
|
|
return ['telegram-git-notifier']; |
54
|
|
|
} |
55
|
|
|
|
56
|
|
|
/** |
57
|
|
|
* @return void |
58
|
|
|
*/ |
59
|
|
|
protected function registerCommands(): void |
60
|
|
|
{ |
61
|
|
|
$this->commands([ |
62
|
|
|
ChangeOwnerConfigJson::class, |
63
|
|
|
SetWebhook::class, |
64
|
|
|
]); |
65
|
|
|
} |
66
|
|
|
|
67
|
|
|
/** |
68
|
|
|
* @return void |
69
|
|
|
*/ |
70
|
|
|
protected function registerAssetPublishing(): void |
71
|
|
|
{ |
72
|
|
|
$configPath = __DIR__.'/../../config/telegram-git-notifier.php'; |
73
|
|
|
$this->publishes([ |
74
|
|
|
$configPath => config_path('telegram-git-notifier.php'), |
75
|
|
|
], 'config'); |
76
|
|
|
|
77
|
|
|
$this->publishes([ |
78
|
|
|
__DIR__.'/../../resources/views' => config('telegram-git-notifier.defaults.paths.views'), |
79
|
|
|
], 'views'); |
80
|
|
|
|
81
|
|
|
$this->publishes([ |
82
|
|
|
__DIR__.'/../../lang' => resource_path('lang/vendor/tg-notifier'), |
83
|
|
|
], 'lang'); |
84
|
|
|
|
85
|
|
|
$this->publishes([ |
86
|
|
|
__DIR__.'/../../../telegram-git-notifier/config/jsons' => config('telegram-git-notifier.data_file.storage_folder'), |
87
|
|
|
], 'config_jsons'); |
88
|
|
|
} |
89
|
|
|
} |
90
|
|
|
|