Passed
Push — master ( e4e152...8fde47 )
by Georgi
02:55
created

ModuleCore::info()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 1
Code Lines 0

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 0
c 0
b 0
f 0
nc 1
nop 0
dl 0
loc 1
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\HasServiceProviders;
11
	
12
	protected $requires = [];
13
	
14
	protected static $view;
15
	
16
	/**
17
	 * Define joints that this class manifests to the other modules
18
	 * 
19
	 * @var array
20
	 */
21
	protected static $joints = [];
22
	
23
	/**
24
	 * Define module alias
25
	 * 
26
	 * @var string
27
	 */
28
	protected static $alias;
29
	
30
	/**
31
	 * Information about the module
32
	 */
33
	public static function info() {}
34
		
35
	/**
36
	 * Directory where module migrations are located
37
	 * 
38
	 * @return string
39
	 */
40
	public static function migrations()
41
	{
42
		return implode(DIRECTORY_SEPARATOR, [static::path(), 'Database', 'Migrations']); 
43
	}
44
			
45
	public static function templates($skin = null)
46
	{
47
		$templatesDir = static::path() . DIRECTORY_SEPARATOR . 'Templates';
48
		
49
		if (! is_dir($templatesDir)) return;
50
		
51
		$skinDir = $templatesDir . DIRECTORY_SEPARATOR . $skin;
52
		
53
		return is_dir($skinDir)? $skinDir: $templatesDir;
54
	}
55
	
56
	public static function translations()
57
	{
58
		return implode(DIRECTORY_SEPARATOR, [static::path(), 'Translations']); 
59
	}		
60
	
61
	/**
62
	 * Module installation method
63
	 * Include statements to be executed on module installation
64
	 * 
65
	 * @return bool - true if installation success, false otherwise
66
	 */
67
	abstract public function install();
68
	
69
	/**
70
	 * Module uninstallation method
71
	 * Include statements to be executed when module in uninstalled
72
	 * 
73
	 * @return bool - true if installation success, false otherwise
74
	 */
75
	abstract public function uninstall();
76
	
77
	final public static function joints()
78
	{
79
		return static::$joints;
80
	}
81
	
82
	final public static function alias()
83
	{
84
		return static::$alias;
85
	}
86
	
87
	final public function migrate()
88
	{
89
		$paths = $this->migrations();
90
		
91
		foreach (is_array($paths)? $paths: [$paths] as $path) {
92
			\Illuminate\Support\Facades\Artisan::call('migrate', ['--path' => $path]);
93
		}
94
	}
95
	
96
	final public function rollback()
97
	{
98
		$paths = $this->migrations();
99
		
100
		foreach (is_array($paths)? $paths: [$paths] as $path) {
101
			\Illuminate\Support\Facades\Artisan::call('migrate:rollback', ['--path' => $path]);
102
		}
103
	}
104
}
105