Test Failed
Push — master ( 8f2167...5d2217 )
by Georgi
08:27
created

ModuleCore::templates()   A

Complexity

Conditions 3
Paths 3

Size

Total Lines 9
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 3
eloc 4
nc 3
nop 1
dl 0
loc 9
rs 10
c 0
b 0
f 0
1
<?php
2
3
namespace Epesi\Core\System\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
	 * Define module label
36
	 * 
37
	 * @var string
38
	 */
39
	protected static $label;
40
41
	/**
42
	 * Module installation method
43
	 * Include statements to be executed on module installation
44
	 *
45
	 * @return bool - true if installation success, false otherwise
46
	 */
47
	public function install() {}
48
	
49
	/**
50
	 * Module uninstallation method
51
	 * Include statements to be executed when module in uninstalled
52
	 *
53
	 * @return bool - true if installation success, false otherwise
54
	 */
55
	public function uninstall() {}
56
	
57
	/**
58
	 * Method called at system boot
59
	 * Can be used same as service controller boot method
60
	 */
61
	public static function boot() {}
62
	
63
	/**
64
	 * Label of the module
65
	 */
66
	public static function label() {
67
		return static::$label?: ucwords(str_ireplace('.', ' ', static::alias()));
68
	}
69
	
70
	/**
71
	 * Information about the module
72
	 */
73
	public static function info() {}
74
		
75
	public static function templates($skin = null)
76
	{
77
		$templatesDir = static::path() . DIRECTORY_SEPARATOR . 'Templates';
78
		
79
		if (! is_dir($templatesDir)) return;
80
		
81
		$skinDir = $templatesDir . DIRECTORY_SEPARATOR . $skin;
82
		
83
		return is_dir($skinDir)? $skinDir: $templatesDir;
84
	}
85
	
86
	public static function translations()
87
	{
88
		return implode(DIRECTORY_SEPARATOR, [static::path(), 'Translations']); 
89
	}		
90
91
	final public static function isInstalled()
92
	{
93
		return ModuleManager::isInstalled(static::class);
94
	}
95
	
96
	final public static function joints()
97
	{
98
		return static::$joints;
99
	}
100
	
101
	final public static function alias()
102
	{
103
		return static::$alias;
104
	}
105
}
106