Completed
Push — master ( bd4222...e5ba92 )
by Arjay
13:31
created

WidgetPublishCommand   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 46
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Importance

Changes 1
Bugs 0 Features 1
Metric Value
c 1
b 0
f 1
dl 0
loc 46
rs 10
wmc 2
lcom 1
cbo 2

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 5 1
A handle() 0 8 1
1
<?php
2
3
namespace Yajra\CMS\Console;
4
5
use Illuminate\Console\Command;
6
use Yajra\CMS\Widgets\EloquentRepository;
7
8
class WidgetPublishCommand extends Command
9
{
10
    /**
11
     * The name and signature of the console command.
12
     *
13
     * @var string
14
     */
15
    protected $signature = 'widget:install {name}';
16
17
    /**
18
     * The console command description.
19
     *
20
     * @var string
21
     */
22
    protected $description = 'Install YajraCMS widget.';
23
24
    /**
25
     * @var \Yajra\CMS\Widgets\EloquentRepository
26
     */
27
    protected $widgets;
28
29
    /**
30
     * Create a new command instance.
31
     *
32
     * @param \Yajra\CMS\Widgets\EloquentRepository $widgets
33
     */
34
    public function __construct(EloquentRepository $widgets)
35
    {
36
        parent::__construct();
37
        $this->widgets = $widgets;
38
    }
39
40
    /**
41
     * Execute the console command.
42
     *
43
     * @return mixed
44
     */
45
    public function handle()
46
    {
47
        $path = app_path('Widgets') . DIRECTORY_SEPARATOR . $this->argument('name') . '.json';
48
49
        $this->widgets->registerManifest($path);
50
51
        $this->info($this->argument('name') . ' widget installed!');
52
    }
53
}
54