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