1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace SleepingOwl\Admin\Console\Installation; |
4
|
|
|
|
5
|
|
|
use Illuminate\Config\Repository; |
6
|
|
|
use Illuminate\Filesystem\Filesystem; |
7
|
|
|
use Illuminate\Console\ConfirmableTrait; |
8
|
|
|
use Illuminate\Console\Command as ConsoleCommand; |
9
|
|
|
use SleepingOwl\Admin\Providers\SleepingOwlServiceProvider; |
10
|
|
|
|
11
|
|
|
abstract class Command extends ConsoleCommand |
12
|
|
|
{ |
13
|
|
|
use ConfirmableTrait; |
14
|
|
|
|
15
|
|
|
/** |
16
|
|
|
* @var Filesystem |
17
|
|
|
*/ |
18
|
|
|
protected $files; |
19
|
|
|
|
20
|
|
|
/** |
21
|
|
|
* @var Repository |
22
|
|
|
*/ |
23
|
|
|
protected $config; |
24
|
|
|
|
25
|
|
|
/** |
26
|
|
|
* Execute the console command. |
27
|
|
|
* |
28
|
|
|
* @param Filesystem $files |
29
|
|
|
*/ |
30
|
|
View Code Duplication |
public function fire(Filesystem $files) |
|
|
|
|
31
|
|
|
{ |
32
|
|
|
if (! defined('SLEEPINGOWL_STUB_PATH')) { |
33
|
|
|
define('SLEEPINGOWL_STUB_PATH', __DIR__.'/stubs'); |
34
|
|
|
} |
35
|
|
|
|
36
|
|
|
if (! $this->confirmToProceed('SleepingOwl Admin')) { |
37
|
|
|
return; |
38
|
|
|
} |
39
|
|
|
|
40
|
|
|
$this->call('vendor:publish', [ |
41
|
|
|
'--tag' => 'config', |
42
|
|
|
'--provider' => SleepingOwlServiceProvider::class, |
43
|
|
|
]); |
44
|
|
|
$this->config = new Repository($this->laravel['config']->get('sleeping_owl')); |
45
|
|
|
|
46
|
|
|
$this->files = $files; |
47
|
|
|
|
48
|
|
|
$this->runInstaller(); |
49
|
|
|
} |
50
|
|
|
|
51
|
|
|
/** |
52
|
|
|
* Execute the console command. |
53
|
|
|
* |
54
|
|
|
* @param Filesystem $files |
55
|
|
|
*/ |
56
|
|
View Code Duplication |
public function handle(Filesystem $files) |
|
|
|
|
57
|
|
|
{ |
58
|
|
|
if (! defined('SLEEPINGOWL_STUB_PATH')) { |
59
|
|
|
define('SLEEPINGOWL_STUB_PATH', __DIR__.'/stubs'); |
60
|
|
|
} |
61
|
|
|
|
62
|
|
|
if (! $this->confirmToProceed('SleepingOwl Admin')) { |
63
|
|
|
return; |
64
|
|
|
} |
65
|
|
|
|
66
|
|
|
$this->call('vendor:publish', [ |
67
|
|
|
'--tag' => 'config', |
68
|
|
|
'--provider' => SleepingOwlServiceProvider::class, |
69
|
|
|
]); |
70
|
|
|
|
71
|
|
|
$this->config = new Repository($this->laravel['config']->get('sleeping_owl')); |
72
|
|
|
|
73
|
|
|
$this->files = $files; |
74
|
|
|
|
75
|
|
|
$this->runInstaller(); |
76
|
|
|
} |
77
|
|
|
|
78
|
|
|
abstract protected function runInstaller(); |
79
|
|
|
|
80
|
|
|
/** |
81
|
|
|
* @return Filesystem |
82
|
|
|
*/ |
83
|
|
|
public function files() |
84
|
|
|
{ |
85
|
|
|
return $this->files; |
86
|
|
|
} |
87
|
|
|
} |
88
|
|
|
|
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.
You can also find more detailed suggestions in the “Code” section of your repository.