|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace LaravelFeature\Console\Command; |
|
4
|
|
|
|
|
5
|
|
|
use Illuminate\Console\Command; |
|
6
|
|
|
use LaravelFeature\Service\FeaturesViewScanner; |
|
7
|
|
|
|
|
8
|
|
|
class ScanViewsForFeaturesCommand extends Command |
|
9
|
|
|
{ |
|
10
|
|
|
/** |
|
11
|
|
|
* The name and signature of the console command. |
|
12
|
|
|
* |
|
13
|
|
|
* @var string |
|
14
|
|
|
*/ |
|
15
|
|
|
protected $signature = 'feature:scan'; |
|
16
|
|
|
|
|
17
|
|
|
/** |
|
18
|
|
|
* The console command description. |
|
19
|
|
|
* |
|
20
|
|
|
* @var string |
|
21
|
|
|
*/ |
|
22
|
|
|
protected $description = 'Scan project views to find new features.'; |
|
23
|
|
|
|
|
24
|
|
|
/** |
|
25
|
|
|
* @var FeaturesViewScanner |
|
26
|
|
|
*/ |
|
27
|
|
|
private $service; |
|
28
|
|
|
|
|
29
|
|
|
|
|
30
|
|
|
/** |
|
31
|
|
|
* Create a new command instance. |
|
32
|
|
|
*/ |
|
33
|
|
|
public function __construct() |
|
34
|
|
|
{ |
|
35
|
|
|
parent::__construct(); |
|
36
|
|
|
|
|
37
|
|
|
$this->service = app()->make(FeaturesViewScanner::class); |
|
38
|
|
|
} |
|
39
|
|
|
|
|
40
|
|
|
/** |
|
41
|
|
|
* Execute the console command. |
|
42
|
|
|
* |
|
43
|
|
|
* @return mixed |
|
44
|
|
|
*/ |
|
45
|
|
|
public function handle() |
|
46
|
|
|
{ |
|
47
|
|
|
$features = $this->service->scan(); |
|
48
|
|
|
$areEnabledByDefault = config('features.scanned_default_enabled'); |
|
49
|
|
|
|
|
50
|
|
|
$this->getOutput()->writeln(''); |
|
51
|
|
|
|
|
52
|
|
|
if (count($features) === 0) { |
|
53
|
|
|
$this->error('No features were found in the project views!'); |
|
54
|
|
|
$this->getOutput()->writeln(''); |
|
55
|
|
|
return; |
|
56
|
|
|
} |
|
57
|
|
|
|
|
58
|
|
|
$this->info(count($features) . ' features found in views:'); |
|
59
|
|
|
$this->getOutput()->writeln(''); |
|
60
|
|
|
|
|
61
|
|
|
foreach ($features as $feature) { |
|
62
|
|
|
$this->getOutput()->writeln('- ' . $feature); |
|
63
|
|
|
} |
|
64
|
|
|
|
|
65
|
|
|
$this->getOutput()->writeln(''); |
|
66
|
|
|
$this->info('All the new features were added to the database with the ' |
|
67
|
|
|
. ($areEnabledByDefault ? 'ENABLED' : 'disabled') . |
|
68
|
|
|
' status by default. Nothing changed for the already present ones.'); |
|
69
|
|
|
|
|
70
|
|
|
$this->getOutput()->writeln(''); |
|
71
|
|
|
} |
|
72
|
|
|
} |
|
73
|
|
|
|