1 | <?php |
||
12 | class AddonNameCommand extends Command |
||
13 | { |
||
14 | use Functions; |
||
15 | |||
16 | /** |
||
17 | * The console command signature. |
||
18 | * |
||
19 | * @var string |
||
20 | */ |
||
21 | protected $signature = 'addon:name |
||
22 | {addon : The desired addon.} |
||
23 | {namespace : The desired namespace.} |
||
24 | {--force : Force remove.} |
||
25 | '; |
||
26 | |||
27 | /** |
||
28 | * The console command description. |
||
29 | * |
||
30 | * @var string |
||
31 | */ |
||
32 | protected $description = 'Set the addon PHP namespace'; |
||
33 | |||
34 | /** |
||
35 | * @var \Illuminate\Filesystem\Filesystem |
||
36 | */ |
||
37 | protected $filesystem; |
||
38 | |||
39 | /** |
||
40 | * @var \Jumilla\Addomnipot\Laravel\Addons\Addon |
||
41 | */ |
||
42 | protected $addon; |
||
43 | |||
44 | /** |
||
45 | * @var string |
||
46 | */ |
||
47 | protected $currentNamespace; |
||
48 | |||
49 | /** |
||
50 | * @var string |
||
51 | */ |
||
52 | protected $newNamespace; |
||
53 | |||
54 | /** |
||
55 | * Execute the console command. |
||
56 | * |
||
57 | * @return mixed |
||
58 | */ |
||
59 | 3 | public function handle(Filesystem $filesystem, AddonEnvironment $env) |
|
104 | |||
105 | /** |
||
106 | * Set the namespace in addon.php, adon.json file. |
||
107 | */ |
||
108 | 1 | protected function setAddonNamespaces() |
|
113 | |||
114 | /** |
||
115 | * Set the namespace in addon.php file. |
||
116 | */ |
||
117 | 1 | protected function setAddonConfigNamespaces() |
|
139 | |||
140 | /** |
||
141 | * Set the namespace in addon.json file. |
||
142 | */ |
||
143 | 1 | protected function setAddonJsonNamespaces() |
|
164 | |||
165 | /** |
||
166 | * Set the PSR-4 namespace in the Composer file. |
||
167 | */ |
||
168 | 1 | protected function setComposerNamespace() |
|
176 | |||
177 | /** |
||
178 | * Set the namespace on the files in the class directory. |
||
179 | */ |
||
180 | 1 | protected function setClassNamespace() |
|
204 | |||
205 | /** |
||
206 | * Set the namespace in the appropriate configuration files. |
||
207 | */ |
||
208 | 1 | protected function setConfigNamespaces() |
|
222 | |||
223 | /** |
||
224 | * Replace the namespace in PHP configuration file. |
||
225 | * |
||
226 | * @param string $path |
||
227 | */ |
||
228 | protected function replaceConfigNamespaces($path) |
||
244 | |||
245 | /** |
||
246 | * Replace the given string in the given file. |
||
247 | * |
||
248 | * @param string $path |
||
249 | * @param string | array $search |
||
250 | * @param string | array $replace |
||
251 | */ |
||
252 | 1 | protected function replaceIn($path, $search, $replace) |
|
260 | } |
||
261 |