1
|
|
|
<?php |
2
|
|
|
namespace Triadev\Leopard\Provider; |
3
|
|
|
|
4
|
|
|
use Illuminate\Foundation\AliasLoader; |
5
|
|
|
use Illuminate\Support\ServiceProvider as BaseServiceProvider; |
6
|
|
|
use Triadev\Leopard\Business\Repository\ElasticsearchRepository; |
7
|
|
|
use Triadev\Leopard\Business\Repository\MappingLogRepository; |
8
|
|
|
use Triadev\Leopard\Console\Commands\Index\Sync; |
9
|
|
|
use Triadev\Leopard\Console\Commands\Mapping\Make; |
10
|
|
|
use Triadev\Leopard\Console\Commands\Mapping\Migrate; |
11
|
|
|
use Triadev\Leopard\Console\Commands\Mapping\Rollback; |
12
|
|
|
use Triadev\Leopard\Contract\ElasticsearchManagerContract; |
13
|
|
|
use Triadev\Leopard\Contract\Repository\ElasticsearchRepositoryContract; |
14
|
|
|
use Triadev\Leopard\Contract\Repository\MappingLogRepositoryContract; |
15
|
|
|
use Triadev\Leopard\ElasticsearchManager; |
16
|
|
|
use Triadev\Leopard\Facade\Leopard; |
17
|
|
|
use Triadev\Es\Provider\ElasticsearchServiceProvider; |
18
|
|
|
|
19
|
|
|
class ServiceProvider extends BaseServiceProvider |
20
|
|
|
{ |
21
|
|
|
/** |
22
|
|
|
* All of the container bindings that should be registered. |
23
|
|
|
* |
24
|
|
|
* @var array |
25
|
|
|
*/ |
26
|
|
|
public $bindings = [ |
27
|
|
|
ElasticsearchRepositoryContract::class => ElasticsearchRepository::class, |
28
|
|
|
MappingLogRepositoryContract::class => MappingLogRepository::class |
29
|
|
|
]; |
30
|
|
|
|
31
|
|
|
/** |
32
|
|
|
* All of the container singletons that should be registered. |
33
|
|
|
* |
34
|
|
|
* @var array |
35
|
|
|
*/ |
36
|
|
|
public $singletons = [ |
37
|
|
|
ElasticsearchManagerContract::class => ElasticsearchManager::class, |
38
|
|
|
]; |
39
|
|
|
|
40
|
|
|
/** |
41
|
|
|
* Bootstrap the application events. |
42
|
|
|
* |
43
|
|
|
* @return void |
44
|
|
|
*/ |
45
|
34 |
|
public function boot() |
46
|
|
|
{ |
47
|
34 |
|
$source = realpath(__DIR__ . '/../Config/config.php'); |
48
|
|
|
|
49
|
34 |
|
$this->publishes([ |
50
|
34 |
|
__DIR__ . '/../Config/config.php' => config_path('leopard.php'), |
51
|
34 |
|
], 'config'); |
52
|
|
|
|
53
|
34 |
|
$this->mergeConfigFrom($source, 'leopard'); |
54
|
|
|
|
55
|
34 |
|
$this->loadMigrationsFrom(__DIR__ . '/../Resources/database/migrations'); |
56
|
|
|
|
57
|
34 |
|
$this->publishes([ |
58
|
34 |
|
__DIR__.'/Resources/database' => database_path(), |
59
|
34 |
|
], 'database'); |
60
|
|
|
|
61
|
34 |
|
$this->commands([ |
62
|
34 |
|
Make::class, |
63
|
|
|
Migrate::class, |
64
|
|
|
Rollback::class, |
65
|
|
|
Sync::class |
66
|
|
|
]); |
67
|
34 |
|
} |
68
|
|
|
|
69
|
|
|
/** |
70
|
|
|
* Register bindings in the container. |
71
|
|
|
* |
72
|
|
|
* @return void |
73
|
|
|
*/ |
74
|
34 |
|
public function register() |
75
|
|
|
{ |
76
|
34 |
|
$this->app->register(ElasticsearchServiceProvider::class); |
77
|
34 |
|
$this->app->register(\Triadev\Es\Dsl\Provider\ServiceProvider::class); |
78
|
34 |
|
$this->app->register(\Triadev\Es\Mapping\Provider\ServiceProvider::class); |
79
|
|
|
|
80
|
34 |
|
AliasLoader::getInstance()->alias('Leopard', Leopard::class); |
81
|
34 |
|
} |
82
|
|
|
} |
83
|
|
|
|