|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace Signifly\DatabaseRefactors\Commands; |
|
4
|
|
|
|
|
5
|
|
|
use Illuminate\Console\GeneratorCommand; |
|
6
|
|
|
use Illuminate\Filesystem\Filesystem; |
|
7
|
|
|
use Illuminate\Support\Composer; |
|
8
|
|
|
|
|
9
|
|
|
class RefactorMakeCommand extends GeneratorCommand |
|
10
|
|
|
{ |
|
11
|
|
|
/** |
|
12
|
|
|
* The console command name. |
|
13
|
|
|
* |
|
14
|
|
|
* @var string |
|
15
|
|
|
*/ |
|
16
|
|
|
protected $name = 'make:refactor'; |
|
17
|
|
|
|
|
18
|
|
|
/** |
|
19
|
|
|
* The console command description. |
|
20
|
|
|
* |
|
21
|
|
|
* @var string |
|
22
|
|
|
*/ |
|
23
|
|
|
protected $description = 'Create a new database refactor class'; |
|
24
|
|
|
|
|
25
|
|
|
/** |
|
26
|
|
|
* The type of class being generated. |
|
27
|
|
|
* |
|
28
|
|
|
* @var string |
|
29
|
|
|
*/ |
|
30
|
|
|
protected $type = 'Refactor'; |
|
31
|
|
|
|
|
32
|
|
|
/** |
|
33
|
|
|
* The Composer instance. |
|
34
|
|
|
* |
|
35
|
|
|
* @var \Illuminate\Support\Composer |
|
36
|
|
|
*/ |
|
37
|
|
|
protected $composer; |
|
38
|
|
|
|
|
39
|
|
|
/** |
|
40
|
|
|
* Create a new command instance. |
|
41
|
|
|
* |
|
42
|
|
|
* @param \Illuminate\Filesystem\Filesystem $files |
|
43
|
|
|
* @param \Illuminate\Support\Composer $composer |
|
44
|
|
|
* @return void |
|
45
|
|
|
*/ |
|
46
|
|
|
public function __construct(Filesystem $files, Composer $composer) |
|
47
|
|
|
{ |
|
48
|
|
|
parent::__construct($files); |
|
49
|
|
|
|
|
50
|
|
|
$this->composer = $composer; |
|
51
|
|
|
} |
|
52
|
|
|
|
|
53
|
|
|
/** |
|
54
|
|
|
* Execute the console command. |
|
55
|
|
|
* |
|
56
|
|
|
* @return void |
|
57
|
|
|
*/ |
|
58
|
|
|
public function handle() |
|
59
|
|
|
{ |
|
60
|
|
|
parent::handle(); |
|
61
|
|
|
|
|
62
|
|
|
$this->composer->dumpAutoloads(); |
|
63
|
|
|
} |
|
64
|
|
|
|
|
65
|
|
|
/** |
|
66
|
|
|
* Get the stub file for the generator. |
|
67
|
|
|
* |
|
68
|
|
|
* @return string |
|
69
|
|
|
*/ |
|
70
|
|
|
protected function getStub() |
|
71
|
|
|
{ |
|
72
|
|
|
return __DIR__.'/stubs/refactor.stub'; |
|
73
|
|
|
} |
|
74
|
|
|
|
|
75
|
|
|
/** |
|
76
|
|
|
* Get the destination class path. |
|
77
|
|
|
* |
|
78
|
|
|
* @param string $name |
|
79
|
|
|
* @return string |
|
80
|
|
|
*/ |
|
81
|
|
|
protected function getPath($name) |
|
82
|
|
|
{ |
|
83
|
|
|
return $this->laravel->databasePath().'/refactors/'.$name.'.php'; |
|
84
|
|
|
} |
|
85
|
|
|
|
|
86
|
|
|
/** |
|
87
|
|
|
* Parse the class name and format according to the root namespace. |
|
88
|
|
|
* |
|
89
|
|
|
* @param string $name |
|
90
|
|
|
* @return string |
|
91
|
|
|
*/ |
|
92
|
|
|
protected function qualifyClass($name) |
|
93
|
|
|
{ |
|
94
|
|
|
return $name; |
|
95
|
|
|
} |
|
96
|
|
|
} |
|
97
|
|
|
|