1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace Itstructure\GridView\Commands; |
4
|
|
|
|
5
|
|
|
use Illuminate\Console\Command; |
6
|
|
|
use Itstructure\GridView\GridViewServiceProvider; |
7
|
|
|
|
8
|
|
|
/** |
9
|
|
|
* Class PublishCommand |
10
|
|
|
* |
11
|
|
|
* @package Itstructure\GridView\Commands |
12
|
|
|
* |
13
|
|
|
* @author Andrey Girnik <[email protected]> |
14
|
|
|
*/ |
15
|
|
|
class PublishCommand extends Command |
16
|
|
|
{ |
17
|
|
|
/** |
18
|
|
|
* The name and signature of the console command. |
19
|
|
|
* @var string |
20
|
|
|
*/ |
21
|
|
|
protected $signature = 'grid_view:publish '. |
22
|
|
|
'{--force : Overwrite existing files by default.}'. |
23
|
|
|
'{--only= : Publish only specific part. Available parts: views, lang.}'; |
24
|
|
|
|
25
|
|
|
/** |
26
|
|
|
* The console command description. |
27
|
|
|
* @var string |
28
|
|
|
*/ |
29
|
|
|
protected $description = 'Publish GridView package parts.'; |
30
|
|
|
|
31
|
|
|
/** |
32
|
|
|
* Execute the console command. |
33
|
|
|
* @return void |
34
|
|
|
*/ |
35
|
|
|
public function handle() |
36
|
|
|
{ |
37
|
|
|
$this->info('Starting publication process of GridView package parts...'); |
38
|
|
|
|
39
|
|
|
$callArguments = ['--provider' => GridViewServiceProvider::class]; |
40
|
|
|
|
41
|
|
|
if ($this->option('only')) { |
42
|
|
|
switch ($this->option('only')) { |
43
|
|
|
case 'views': |
44
|
|
|
$this->info('Publish just a part: views.'); |
45
|
|
|
$callArguments['--tag'] = 'views'; |
46
|
|
|
break; |
47
|
|
|
|
48
|
|
|
case 'lang': |
49
|
|
|
$this->info('Publish just a part: lang.'); |
50
|
|
|
$callArguments['--tag'] = 'lang'; |
51
|
|
|
break; |
52
|
|
|
|
53
|
|
|
default: |
54
|
|
|
$this->error('Invalid "only" argument value!'); |
55
|
|
|
return; |
56
|
|
|
break; |
|
|
|
|
57
|
|
|
} |
58
|
|
|
|
59
|
|
|
} else { |
60
|
|
|
$this->info('Publish all parts: views, lang.'); |
61
|
|
|
} |
62
|
|
|
|
63
|
|
|
if ($this->option('force')) { |
64
|
|
|
$this->warn('Force publishing.'); |
65
|
|
|
$callArguments['--force'] = true; |
66
|
|
|
} |
67
|
|
|
|
68
|
|
|
$this->call('vendor:publish', $callArguments); |
69
|
|
|
} |
70
|
|
|
} |
71
|
|
|
|
The
break
statement is not necessary if it is preceded for example by areturn
statement:If you would like to keep this construct to be consistent with other
case
statements, you can safely mark this issue as a false-positive.