|
1
|
|
|
<?php namespace KitLoong\MigrationsGenerator; |
|
2
|
|
|
|
|
3
|
|
|
use Illuminate\Foundation\Application; |
|
4
|
|
|
use Illuminate\Support\ServiceProvider; |
|
5
|
|
|
use Xethron\MigrationsGenerator\MigrateGenerateCommand; |
|
6
|
|
|
|
|
7
|
|
|
class MigrationsGeneratorServiceProvider extends ServiceProvider |
|
8
|
|
|
{ |
|
9
|
|
|
/** |
|
10
|
|
|
* Indicates if loading of the provider is deferred. |
|
11
|
|
|
* |
|
12
|
|
|
* @var bool |
|
13
|
|
|
*/ |
|
14
|
|
|
protected $defer = false; |
|
15
|
|
|
|
|
16
|
|
|
/** |
|
17
|
|
|
* Register the service provider. |
|
18
|
|
|
* |
|
19
|
|
|
* @return void |
|
20
|
|
|
*/ |
|
21
|
|
|
public function register() |
|
22
|
|
|
{ |
|
23
|
|
|
$this->registerConfig(); |
|
24
|
|
|
|
|
25
|
|
|
$this->app->singleton( |
|
26
|
|
|
'migration.generate', |
|
27
|
|
|
function (Application $app) { |
|
28
|
|
|
return new MigrateGenerateCommand( |
|
29
|
|
|
$app->make('Way\Generators\Generator'), |
|
30
|
|
|
$app->make('Way\Generators\Filesystem\Filesystem'), |
|
31
|
|
|
$app->make('Way\Generators\Compilers\TemplateCompiler'), |
|
32
|
|
|
$app->make('migration.repository'), |
|
33
|
|
|
$app->make('config') |
|
34
|
|
|
); |
|
35
|
|
|
} |
|
36
|
|
|
); |
|
37
|
|
|
|
|
38
|
|
|
$this->commands('migration.generate'); |
|
39
|
|
|
|
|
40
|
|
|
// Bind the Repository Interface to $app['migrations.repository'] |
|
41
|
|
|
$this->app->bind('Illuminate\Database\Migrations\MigrationRepositoryInterface', function ($app) { |
|
42
|
|
|
return $app['migration.repository']; |
|
43
|
|
|
}); |
|
44
|
|
|
} |
|
45
|
|
|
|
|
46
|
|
|
/** |
|
47
|
|
|
* Bootstrap the application events. |
|
48
|
|
|
* |
|
49
|
|
|
* @return void |
|
50
|
|
|
*/ |
|
51
|
|
|
public function boot() |
|
52
|
|
|
{ |
|
53
|
|
|
// |
|
54
|
|
|
} |
|
55
|
|
|
|
|
56
|
|
|
/** |
|
57
|
|
|
* Get the services provided by the provider. |
|
58
|
|
|
* |
|
59
|
|
|
* @return array |
|
60
|
|
|
*/ |
|
61
|
|
|
public function provides() |
|
62
|
|
|
{ |
|
63
|
|
|
return array(); |
|
64
|
|
|
} |
|
65
|
|
|
|
|
66
|
|
|
/** |
|
67
|
|
|
* Register the config paths |
|
68
|
|
|
*/ |
|
69
|
|
|
protected function registerConfig() |
|
70
|
|
|
{ |
|
71
|
|
|
$packageConfigFile = __DIR__.'/../../config/config.php'; |
|
72
|
|
|
$this->app['config']->set('generators.config', $this->app['files']->getRequire($packageConfigFile)); |
|
73
|
|
|
} |
|
74
|
|
|
} |
|
75
|
|
|
|