|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace JeroenNoten\LaravelAdminLte\Console\PackageResources; |
|
4
|
|
|
|
|
5
|
|
|
use JeroenNoten\LaravelAdminLte\Helpers\CommandHelper; |
|
6
|
|
|
|
|
7
|
|
|
class ConfigResource extends PackageResource |
|
8
|
|
|
{ |
|
9
|
|
|
/** |
|
10
|
|
|
* Create a new resource instance. |
|
11
|
|
|
* |
|
12
|
|
|
* @return void |
|
13
|
|
|
*/ |
|
14
|
13 |
|
public function __construct() |
|
15
|
|
|
{ |
|
16
|
|
|
// Fill the resource data. |
|
17
|
|
|
|
|
18
|
13 |
|
$this->description = 'The default package configuration file'; |
|
19
|
13 |
|
$this->source = CommandHelper::getPackagePath('config/adminlte.php'); |
|
20
|
13 |
|
$this->target = config_path('adminlte.php'); |
|
21
|
13 |
|
$this->required = true; |
|
22
|
|
|
|
|
23
|
|
|
// Fill the set of installation messages. |
|
24
|
|
|
|
|
25
|
13 |
|
$this->messages = [ |
|
26
|
|
|
'install' => 'Install the package config file?', |
|
27
|
|
|
'overwrite' => 'The config file already exists. Want to replace it?', |
|
28
|
|
|
'success' => 'Configuration file installed successfully.', |
|
29
|
|
|
]; |
|
30
|
13 |
|
} |
|
31
|
|
|
|
|
32
|
|
|
/** |
|
33
|
|
|
* Install/Export the resource. |
|
34
|
|
|
* |
|
35
|
|
|
* @return void |
|
36
|
|
|
*/ |
|
37
|
8 |
|
public function install() |
|
38
|
|
|
{ |
|
39
|
|
|
// Install the configuration file. |
|
40
|
|
|
|
|
41
|
8 |
|
CommandHelper::ensureDirectoryExists(dirname($this->target)); |
|
42
|
8 |
|
copy($this->source, $this->target); |
|
43
|
8 |
|
} |
|
44
|
|
|
|
|
45
|
|
|
/** |
|
46
|
|
|
* Uninstall/Remove the resource. |
|
47
|
|
|
* |
|
48
|
|
|
* @return void |
|
49
|
|
|
*/ |
|
50
|
8 |
|
public function uninstall() |
|
51
|
|
|
{ |
|
52
|
|
|
// Uninstall the configuration file. |
|
53
|
|
|
|
|
54
|
8 |
|
if (is_file($this->target)) { |
|
55
|
8 |
|
unlink($this->target); |
|
56
|
|
|
} |
|
57
|
8 |
|
} |
|
58
|
|
|
|
|
59
|
|
|
/** |
|
60
|
|
|
* Check if the resource already exists on the target destination. |
|
61
|
|
|
* |
|
62
|
|
|
* @return bool |
|
63
|
|
|
*/ |
|
64
|
8 |
|
public function exists() |
|
65
|
|
|
{ |
|
66
|
8 |
|
return is_file($this->target); |
|
67
|
|
|
} |
|
68
|
|
|
|
|
69
|
|
|
/** |
|
70
|
|
|
* Check if the resource is correctly installed. |
|
71
|
|
|
* |
|
72
|
|
|
* @return bool |
|
73
|
|
|
*/ |
|
74
|
8 |
|
public function installed() |
|
75
|
|
|
{ |
|
76
|
8 |
|
return CommandHelper::compareFiles($this->source, $this->target); |
|
77
|
|
|
} |
|
78
|
|
|
} |
|
79
|
|
|
|