Passed
Push — master ( 370e51...582fe4 )
by Georgi
03:26
created

ModuleCore::isInstalled()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 1
c 0
b 0
f 0
nc 1
nop 0
dl 0
loc 3
rs 10
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