|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace Dimsav\Translatable; |
|
4
|
|
|
|
|
5
|
|
|
use Dimsav\Translatable\Console\MigrationCreator; |
|
6
|
|
|
use Dimsav\Translatable\Console\TranslateTableCommand; |
|
7
|
|
|
use Illuminate\Foundation\Providers\ArtisanServiceProvider; |
|
8
|
|
|
|
|
9
|
|
|
class TranslatableArtisanProvider extends ArtisanServiceProvider |
|
10
|
|
|
{ |
|
11
|
|
|
public function __construct($app) |
|
12
|
|
|
{ |
|
13
|
|
|
parent::__construct($app); |
|
14
|
|
|
$this->devCommands = array_merge($this->devCommands, [ |
|
15
|
|
|
'TranslateTable' => 'command.translate.table', |
|
16
|
|
|
]); |
|
17
|
|
|
} |
|
18
|
|
|
|
|
19
|
|
|
public function register() |
|
20
|
|
|
{ |
|
21
|
|
|
parent::register(); |
|
22
|
|
|
$this->app->singleton('translate.creator', function ($app) { |
|
23
|
|
|
return new MigrationCreator($app['files']); |
|
24
|
|
|
}); |
|
25
|
|
|
} |
|
26
|
|
|
|
|
27
|
|
|
/** |
|
28
|
|
|
* Register the command. |
|
29
|
|
|
* |
|
30
|
|
|
* @return void |
|
31
|
|
|
*/ |
|
32
|
|
|
protected function registerTranslateTableCommand() |
|
33
|
|
|
{ |
|
34
|
|
|
$this->app->singleton('command.translate.table', function ($app) { |
|
35
|
|
|
// Once we have the migration creator registered, we will create the command |
|
36
|
|
|
// and inject the creator. The creator is responsible for the actual file |
|
37
|
|
|
// creation of the migrations, and may be extended by these developers. |
|
38
|
|
|
$creator = $app['translate.creator']; |
|
39
|
|
|
|
|
40
|
|
|
$composer = $app['composer']; |
|
41
|
|
|
|
|
42
|
|
|
return new TranslateTableCommand($creator, $composer); |
|
43
|
|
|
}); |
|
44
|
|
|
} |
|
45
|
|
|
|
|
46
|
|
|
/** |
|
47
|
|
|
* Register the migration creator. |
|
48
|
|
|
* |
|
49
|
|
|
* @return void |
|
50
|
|
|
*/ |
|
51
|
|
|
protected function registerCreator() |
|
52
|
|
|
{ |
|
53
|
|
|
$this->app->singleton('migration.creator', function ($app) { |
|
54
|
|
|
return new MigrationCreator($app['files']); |
|
55
|
|
|
}); |
|
56
|
|
|
} |
|
57
|
|
|
} |
|
58
|
|
|
|