1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace Distilleries\Contentful; |
4
|
|
|
|
5
|
|
|
use Illuminate\Support\ServiceProvider as BaseServiceProvider; |
6
|
|
|
|
7
|
|
|
class ServiceProvider extends BaseServiceProvider |
8
|
|
|
{ |
9
|
|
|
/** |
10
|
|
|
* Package Laravel specific internal name. |
11
|
|
|
* |
12
|
|
|
* @var string |
13
|
|
|
*/ |
14
|
|
|
protected $package = 'contentful'; |
15
|
|
|
|
16
|
|
|
/** |
17
|
|
|
* {@inheritdoc} |
18
|
|
|
*/ |
19
|
|
|
public function provides(): array |
20
|
|
|
{ |
21
|
|
|
return [ |
22
|
|
|
'command.contentful.model', |
23
|
|
|
'command.contentful.migration', |
24
|
|
|
'command.contentful.sync', |
25
|
|
|
'command.contentful.sync-data', |
26
|
|
|
'command.contentful.sync-flatten', |
27
|
|
|
'command.contentful.sync-locales', |
28
|
|
|
'command.contentful.import-clean', |
29
|
|
|
'command.contentful.import-publish', |
30
|
|
|
]; |
31
|
|
|
} |
32
|
|
|
|
33
|
|
|
/** |
34
|
|
|
* Bootstrap any application services. |
35
|
|
|
* |
36
|
|
|
* @return void |
37
|
|
|
*/ |
38
|
|
|
public function boot() |
39
|
|
|
{ |
40
|
|
|
$this->publishes([ |
41
|
|
|
__DIR__ . '/../../config/config.php' => base_path('config/' . $this->package . '.php'), |
42
|
|
|
], 'config'); |
43
|
|
|
|
44
|
|
|
$this->loadMigrationsFrom(__DIR__ . '/../../database/migrations/'); |
45
|
|
|
} |
46
|
|
|
|
47
|
|
|
/** |
48
|
|
|
* Register any application services. |
49
|
|
|
* |
50
|
|
|
* @return void |
51
|
|
|
*/ |
52
|
|
|
public function register() |
53
|
|
|
{ |
54
|
|
|
$this->mergeConfigFrom(__DIR__ . '/../../config/config.php', $this->package); |
55
|
|
|
|
56
|
|
|
$this->app->bind(Api\DeliveryApi::class, Api\Delivery\Cached::class); |
57
|
|
|
$this->app->bind(Api\ManagementApi::class, Api\Management\Api::class); |
58
|
|
|
$this->app->bind(Api\SyncApi::class, Api\Sync\Api::class); |
59
|
|
|
$this->app->bind(Api\UploadApi::class, Api\Upload\Api::class); |
60
|
|
|
|
61
|
|
|
if ($this->app->runningInConsole()) { |
62
|
|
|
$this->registerCommands(); |
63
|
|
|
} |
64
|
|
|
} |
65
|
|
|
|
66
|
|
|
/** |
67
|
|
|
* Register Artisan commands. |
68
|
|
|
* |
69
|
|
|
* @return void |
70
|
|
|
*/ |
71
|
|
|
private function registerCommands() |
72
|
|
|
{ |
73
|
|
|
$this->app->singleton('command.contentful.model', function () { |
74
|
|
|
return new Commands\Generators\Models(app(Api\ManagementApi::class)); |
75
|
|
|
}); |
76
|
|
|
$this->app->singleton('command.contentful.migration', function () { |
77
|
|
|
return new Commands\Generators\Migrations(app(Api\ManagementApi::class)); |
78
|
|
|
}); |
79
|
|
|
$this->app->singleton('command.contentful.sync', function () { |
80
|
|
|
return new Commands\Sync\Sync; |
81
|
|
|
}); |
82
|
|
|
$this->app->singleton('command.contentful.sync-data', function () { |
83
|
|
|
return new Commands\Sync\SyncData(app(Api\SyncApi::class)); |
84
|
|
|
}); |
85
|
|
|
$this->app->singleton('command.contentful.sync-flatten', function () { |
86
|
|
|
return new Commands\Sync\SyncFlatten; |
87
|
|
|
}); |
88
|
|
|
$this->app->singleton('command.contentful.sync-locales', function () { |
89
|
|
|
return new Commands\Sync\SyncLocales(app(Api\ManagementApi::class)); |
90
|
|
|
}); |
91
|
|
|
$this->app->singleton('command.contentful.import-clean', function () { |
92
|
|
|
return new Commands\Import\ImportClean(app(Api\ManagementApi::class)); |
93
|
|
|
}); |
94
|
|
|
$this->app->singleton('command.contentful.import-publish', function () { |
95
|
|
|
return new Commands\Import\ImportPublish(app(Api\ManagementApi::class)); |
96
|
|
|
}); |
97
|
|
|
|
98
|
|
|
$this->commands('command.contentful.model'); |
99
|
|
|
$this->commands('command.contentful.migration'); |
100
|
|
|
$this->commands('command.contentful.sync'); |
101
|
|
|
$this->commands('command.contentful.sync-data'); |
102
|
|
|
$this->commands('command.contentful.sync-flatten'); |
103
|
|
|
$this->commands('command.contentful.sync-locales'); |
104
|
|
|
$this->commands('command.contentful.import-clean'); |
105
|
|
|
$this->commands('command.contentful.import-publish'); |
106
|
|
|
} |
107
|
|
|
} |
108
|
|
|
|