1 | <?php |
||
10 | class ForgeServiceProvider extends ServiceProvider |
||
11 | { |
||
12 | /** |
||
13 | * Bootstrap the application services. |
||
14 | */ |
||
15 | public function boot() |
||
16 | { |
||
17 | $this->app->singleton(Forge::class, function ($app) { |
||
18 | $token = $app['config']->get('forge.token'); |
||
19 | $forge = new Forge(new ApiProvider($token)); |
||
20 | |||
21 | // Set default credentials (if any exists). |
||
22 | $defaultCredentials = $app['config']->get('forge.default_credentials', []); |
||
23 | |||
24 | if (!count($defaultCredentials)) { |
||
25 | return $forge; |
||
26 | } |
||
27 | |||
28 | foreach ($defaultCredentials as $provider => $credential) { |
||
29 | Factory::setDefaultCredential($provider, $credential); |
||
30 | } |
||
31 | |||
32 | return $forge; |
||
33 | }); |
||
34 | |||
35 | // Publish configuration file. |
||
36 | $this->publishes([ |
||
37 | __DIR__.'/configs/forge.php' => config_path('forge.php'), |
||
38 | ]); |
||
39 | |||
40 | // Register console commands. |
||
41 | if ($this->app->runningInConsole()) { |
||
42 | $this->commands([ |
||
43 | Commands\ForgeCredentials::class, |
||
44 | Commands\ForgeServers::class, |
||
45 | ]); |
||
46 | } |
||
47 | } |
||
48 | |||
49 | /** |
||
50 | * Register the application services. |
||
51 | */ |
||
52 | public function register() |
||
53 | { |
||
54 | // |
||
55 | } |
||
56 | } |
||
57 |