|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace Terranet\Administrator\Console; |
|
4
|
|
|
|
|
5
|
|
|
use Illuminate\Console\GeneratorCommand; |
|
|
|
|
|
|
6
|
|
|
use Illuminate\Support\Str; |
|
7
|
|
|
|
|
8
|
|
|
class ResourceMakeCommand extends GeneratorCommand |
|
9
|
|
|
{ |
|
10
|
|
|
/** |
|
11
|
|
|
* The console command name. |
|
12
|
|
|
* |
|
13
|
|
|
* @var string |
|
14
|
|
|
*/ |
|
15
|
|
|
protected $signature = 'administrator:resource {name} {model?}'; |
|
16
|
|
|
|
|
17
|
|
|
/** |
|
18
|
|
|
* The console command description. |
|
19
|
|
|
* |
|
20
|
|
|
* @var string |
|
21
|
|
|
*/ |
|
22
|
|
|
protected $description = 'Create new administrator resource.'; |
|
23
|
|
|
|
|
24
|
|
|
/** |
|
25
|
|
|
* The type of class being generated. |
|
26
|
|
|
* |
|
27
|
|
|
* @var string |
|
28
|
|
|
*/ |
|
29
|
|
|
protected $type = 'Module'; |
|
30
|
|
|
|
|
31
|
|
|
/** |
|
32
|
|
|
* Get the stub file for the generator. |
|
33
|
|
|
* |
|
34
|
|
|
* @return string |
|
35
|
|
|
*/ |
|
36
|
|
|
protected function getStub() |
|
37
|
|
|
{ |
|
38
|
|
|
return __DIR__.'/stubs/module.stub'; |
|
39
|
|
|
} |
|
40
|
|
|
|
|
41
|
|
|
/** |
|
42
|
|
|
* Get the default namespace for the class. |
|
43
|
|
|
* |
|
44
|
|
|
* @param string $rootNamespace |
|
45
|
|
|
* |
|
46
|
|
|
* @return string |
|
47
|
|
|
*/ |
|
48
|
|
|
protected function getDefaultNamespace($rootNamespace) |
|
49
|
|
|
{ |
|
50
|
|
|
return $rootNamespace.'\Http\Terranet\Administrator\Modules'; |
|
51
|
|
|
} |
|
52
|
|
|
|
|
53
|
|
|
/** |
|
54
|
|
|
* Build the class with the given name. |
|
55
|
|
|
* |
|
56
|
|
|
* @param string $name |
|
57
|
|
|
* |
|
58
|
|
|
* @return string |
|
59
|
|
|
*/ |
|
60
|
|
|
protected function buildClass($name) |
|
61
|
|
|
{ |
|
62
|
|
|
$stub = parent::buildClass($name); |
|
63
|
|
|
|
|
64
|
|
|
if ($model = $this->argument('model')) { |
|
65
|
|
|
if (!Str::startsWith($model, $namespace = $this->laravel->getNamespace())) { |
|
66
|
|
|
$model = "{$namespace}\\{$model}"; |
|
67
|
|
|
} |
|
68
|
|
|
} |
|
69
|
|
|
|
|
70
|
|
|
return $this->replaceModel($stub, $model); |
|
71
|
|
|
} |
|
72
|
|
|
|
|
73
|
|
|
/** |
|
74
|
|
|
* Replace the model name for the given stub. |
|
75
|
|
|
* |
|
76
|
|
|
* @param string $stub |
|
77
|
|
|
* @param string $name |
|
78
|
|
|
* |
|
79
|
|
|
* @return string |
|
80
|
|
|
*/ |
|
81
|
|
|
protected function replaceModel($stub, $name) |
|
82
|
|
|
{ |
|
83
|
|
|
return str_replace('DummyModel', $name ?: '\App\User', $stub); |
|
84
|
|
|
} |
|
85
|
|
|
|
|
86
|
|
|
/** |
|
87
|
|
|
* Get the console command options. |
|
88
|
|
|
* |
|
89
|
|
|
* @return array |
|
90
|
|
|
*/ |
|
91
|
|
|
protected function getOptions() |
|
92
|
|
|
{ |
|
93
|
|
|
return []; |
|
94
|
|
|
} |
|
95
|
|
|
} |
|
96
|
|
|
|
The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g.
excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths