1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace Blok\Repository\Commands; |
4
|
|
|
|
5
|
|
|
use Illuminate\Console\GeneratorCommand; |
|
|
|
|
6
|
|
|
use Symfony\Component\Console\Input\InputArgument; |
|
|
|
|
7
|
|
|
use Symfony\Component\Console\Input\InputOption; |
|
|
|
|
8
|
|
|
|
9
|
|
|
class RepositoryMakeCommand extends GeneratorCommand |
10
|
|
|
{ |
11
|
|
|
/** |
12
|
|
|
* The console command name. |
13
|
|
|
* |
14
|
|
|
* @var string |
15
|
|
|
*/ |
16
|
|
|
protected $name = 'make:repository'; |
17
|
|
|
|
18
|
|
|
/** |
19
|
|
|
* The console command description. |
20
|
|
|
* |
21
|
|
|
* @var string |
22
|
|
|
*/ |
23
|
|
|
protected $description = 'Create a new repository class'; |
24
|
|
|
|
25
|
|
|
/** |
26
|
|
|
* The type of class being generated. |
27
|
|
|
* |
28
|
|
|
* @var string |
29
|
|
|
*/ |
30
|
|
|
protected $type = 'Repository'; |
31
|
|
|
|
32
|
|
|
/** |
33
|
|
|
* Get the stub file for the generator. |
34
|
|
|
* |
35
|
|
|
* @return string |
36
|
|
|
*/ |
37
|
|
|
protected function getStub() |
38
|
|
|
{ |
39
|
|
|
return __DIR__.'/stubs/repository.stub'; |
40
|
|
|
} |
41
|
|
|
|
42
|
|
|
/** |
43
|
|
|
* Replace the class name for the given stub. |
44
|
|
|
* |
45
|
|
|
* @param string $stub |
46
|
|
|
* @param string $name |
47
|
|
|
* @return string |
48
|
|
|
*/ |
49
|
|
|
protected function replaceClass($stub, $name) |
50
|
|
|
{ |
51
|
|
|
$class = str_replace($this->getNamespace($name).'\\', '', $name); |
52
|
|
|
|
53
|
|
|
if ($this->option('model')) { |
54
|
|
|
$model = $this->option('model'); |
55
|
|
|
} else { |
56
|
|
|
$modelName = "\App\\".str_replace("Repository", "", $class); |
57
|
|
|
$model = $this->ask("From which model do you want to create the repository ?", $modelName); |
58
|
|
|
} |
59
|
|
|
|
60
|
|
|
return str_replace(['DummyClass', 'DummyModel'], [$class, $model], $stub); |
61
|
|
|
} |
62
|
|
|
|
63
|
|
|
/** |
64
|
|
|
* Get the default namespace for the class. |
65
|
|
|
* |
66
|
|
|
* @param string $rootNamespace |
67
|
|
|
* @return string |
68
|
|
|
*/ |
69
|
|
|
protected function getDefaultNamespace($rootNamespace) |
70
|
|
|
{ |
71
|
|
|
return $rootNamespace.'\Repositories'; |
72
|
|
|
} |
73
|
|
|
|
74
|
|
|
|
75
|
|
|
|
76
|
|
|
/** |
77
|
|
|
* Get the console command arguments. |
78
|
|
|
* |
79
|
|
|
* @return array |
80
|
|
|
*/ |
81
|
|
|
protected function getArguments() |
82
|
|
|
{ |
83
|
|
|
return [ |
84
|
|
|
[ |
85
|
|
|
'name', InputArgument::REQUIRED, 'The name of the Repository' |
86
|
|
|
], |
87
|
|
|
]; |
88
|
|
|
} |
89
|
|
|
|
90
|
|
|
/** |
91
|
|
|
* Get the console command options. |
92
|
|
|
* |
93
|
|
|
* @return array |
94
|
|
|
*/ |
95
|
|
|
protected function getOptions() |
96
|
|
|
{ |
97
|
|
|
return [ |
98
|
|
|
['model', 'm', InputOption::VALUE_OPTIONAL, 'The base model of this repository.'], |
99
|
|
|
]; |
100
|
|
|
} |
101
|
|
|
} |
102
|
|
|
|
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