|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace Epesi\Core\System\Integration\Modules; |
|
4
|
|
|
|
|
5
|
|
|
abstract class ModuleCore |
|
6
|
|
|
{ |
|
7
|
|
|
use Concerns\HasModule; |
|
8
|
|
|
use Concerns\HasAssets; |
|
9
|
|
|
use Concerns\HasAssetsAccess; |
|
10
|
|
|
use Concerns\HasDependencies; |
|
11
|
|
|
use Concerns\HasMigrations; |
|
12
|
|
|
|
|
13
|
|
|
/** |
|
14
|
|
|
* @var string Define the default view class for the module |
|
15
|
|
|
* |
|
16
|
|
|
* By default it is <module-name> . 'View' |
|
17
|
|
|
*/ |
|
18
|
|
|
protected static $view; |
|
19
|
|
|
|
|
20
|
|
|
/** |
|
21
|
|
|
* Define joints that this class manifests to the other modules |
|
22
|
|
|
* |
|
23
|
|
|
* @var array |
|
24
|
|
|
*/ |
|
25
|
|
|
protected static $joints = []; |
|
26
|
|
|
|
|
27
|
|
|
/** |
|
28
|
|
|
* Define module alias |
|
29
|
|
|
* |
|
30
|
|
|
* @var string |
|
31
|
|
|
*/ |
|
32
|
|
|
protected static $alias; |
|
33
|
|
|
|
|
34
|
|
|
/** |
|
35
|
|
|
* Module installation method |
|
36
|
|
|
* Include statements to be executed on module installation |
|
37
|
|
|
* |
|
38
|
|
|
* @return bool - true if installation success, false otherwise |
|
39
|
|
|
*/ |
|
40
|
|
|
abstract public function install(); |
|
41
|
|
|
|
|
42
|
|
|
/** |
|
43
|
|
|
* Module uninstallation method |
|
44
|
|
|
* Include statements to be executed when module in uninstalled |
|
45
|
|
|
* |
|
46
|
|
|
* @return bool - true if installation success, false otherwise |
|
47
|
|
|
*/ |
|
48
|
|
|
abstract public function uninstall(); |
|
49
|
|
|
|
|
50
|
|
|
/** |
|
51
|
|
|
* Method called at system boot |
|
52
|
|
|
* Can be used same as service controller boot method |
|
53
|
|
|
*/ |
|
54
|
|
|
public static function boot() {} |
|
55
|
|
|
|
|
56
|
|
|
/** |
|
57
|
|
|
* Information about the module |
|
58
|
|
|
*/ |
|
59
|
|
|
public static function info() {} |
|
60
|
|
|
|
|
61
|
|
|
public static function templates($skin = null) |
|
62
|
|
|
{ |
|
63
|
|
|
$templatesDir = static::path() . DIRECTORY_SEPARATOR . 'Templates'; |
|
64
|
|
|
|
|
65
|
|
|
if (! is_dir($templatesDir)) return; |
|
66
|
|
|
|
|
67
|
|
|
$skinDir = $templatesDir . DIRECTORY_SEPARATOR . $skin; |
|
68
|
|
|
|
|
69
|
|
|
return is_dir($skinDir)? $skinDir: $templatesDir; |
|
70
|
|
|
} |
|
71
|
|
|
|
|
72
|
|
|
public static function translations() |
|
73
|
|
|
{ |
|
74
|
|
|
return implode(DIRECTORY_SEPARATOR, [static::path(), 'Translations']); |
|
75
|
|
|
} |
|
76
|
|
|
|
|
77
|
|
|
final public static function isInstalled() |
|
78
|
|
|
{ |
|
79
|
|
|
return ModuleManager::isInstalled(static::class); |
|
80
|
|
|
} |
|
81
|
|
|
|
|
82
|
|
|
final public static function joints() |
|
83
|
|
|
{ |
|
84
|
|
|
return static::$joints; |
|
85
|
|
|
} |
|
86
|
|
|
|
|
87
|
|
|
final public static function alias() |
|
88
|
|
|
{ |
|
89
|
|
|
return static::$alias; |
|
90
|
|
|
} |
|
91
|
|
|
} |
|
92
|
|
|
|