1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
/** |
4
|
|
|
* Quantum PHP Framework |
5
|
|
|
* |
6
|
|
|
* An open source software development framework for PHP |
7
|
|
|
* |
8
|
|
|
* @package Quantum |
9
|
|
|
* @author Arman Ag. <[email protected]> |
10
|
|
|
* @copyright Copyright (c) 2018 Softberg LLC (https://softberg.org) |
11
|
|
|
* @link http://quantum.softberg.org/ |
12
|
|
|
* @since 2.3.0 |
13
|
|
|
*/ |
14
|
|
|
|
15
|
|
|
namespace Quantum\Loader; |
16
|
|
|
|
17
|
|
|
|
18
|
|
|
use Quantum\Exceptions\ConfigException; |
19
|
|
|
|
20
|
|
|
/** |
21
|
|
|
* Class Setup |
22
|
|
|
* @package Quantum\Loader |
23
|
|
|
*/ |
24
|
|
|
class Setup |
25
|
|
|
{ |
26
|
|
|
/** |
27
|
|
|
* @var bool |
28
|
|
|
*/ |
29
|
|
|
protected $hierarchical = false; |
30
|
|
|
|
31
|
|
|
/** |
32
|
|
|
* @var string|null |
33
|
|
|
*/ |
34
|
|
|
protected $module; |
35
|
|
|
|
36
|
|
|
/** |
37
|
|
|
* @var string|null |
38
|
|
|
*/ |
39
|
|
|
protected $env; |
40
|
|
|
|
41
|
|
|
/** |
42
|
|
|
* @var string|null |
43
|
|
|
*/ |
44
|
|
|
protected $fileName; |
45
|
|
|
|
46
|
|
|
/** |
47
|
|
|
* @var string|string |
48
|
|
|
*/ |
49
|
|
|
protected $exceptionMessage; |
50
|
|
|
|
51
|
|
|
/** |
52
|
|
|
* Setup constructor. |
53
|
|
|
* @param string|null $env |
54
|
|
|
* @param string|null $fileName |
55
|
|
|
* @param bool $hierarchical |
56
|
|
|
* @param string|null $module |
57
|
|
|
* @param string $exceptionMessage |
58
|
|
|
*/ |
59
|
|
|
public function __construct($env = null, $fileName = null, $hierarchical = false, $module = null, $exceptionMessage = ConfigException::CONFIG_FILE_NOT_FOUND) |
60
|
|
|
{ |
61
|
|
|
$this->env = $env; |
62
|
|
|
$this->fileName = $fileName; |
63
|
|
|
$this->hierarchical = $hierarchical; |
64
|
|
|
$this->module = $module ?: current_module(); |
65
|
|
|
$this->exceptionMessage = $exceptionMessage; |
66
|
|
|
} |
67
|
|
|
|
68
|
|
|
/** |
69
|
|
|
* Sets the env |
70
|
|
|
* @param string $env |
71
|
|
|
* @return $this |
72
|
|
|
*/ |
73
|
|
|
public function setEnv($env) { |
74
|
|
|
$this->env = $env; |
75
|
|
|
return $this; |
76
|
|
|
} |
77
|
|
|
|
78
|
|
|
/** |
79
|
|
|
* Gets the env |
80
|
|
|
* @return string|null |
81
|
|
|
*/ |
82
|
|
|
public function getEnv() { |
83
|
|
|
return $this->env; |
84
|
|
|
} |
85
|
|
|
|
86
|
|
|
/** |
87
|
|
|
* Set the filename |
88
|
|
|
* @param string $fileName |
89
|
|
|
* @return $this |
90
|
|
|
*/ |
91
|
|
|
public function setFilename($fileName) { |
92
|
|
|
$this->fileName = $fileName; |
93
|
|
|
return $this; |
94
|
|
|
} |
95
|
|
|
|
96
|
|
|
/** |
97
|
|
|
* Gets the filename |
98
|
|
|
* @return string|null |
99
|
|
|
*/ |
100
|
|
|
public function getFilename() { |
101
|
|
|
return $this->fileName; |
102
|
|
|
} |
103
|
|
|
|
104
|
|
|
/** |
105
|
|
|
* Sets the module |
106
|
|
|
* @param string $module |
107
|
|
|
* @return $this |
108
|
|
|
*/ |
109
|
|
|
public function setModule($module) { |
110
|
|
|
$this->module = $module; |
111
|
|
|
return $this; |
112
|
|
|
} |
113
|
|
|
|
114
|
|
|
/** |
115
|
|
|
* Gets the module |
116
|
|
|
* @return string|null |
117
|
|
|
*/ |
118
|
|
|
public function getModule() { |
119
|
|
|
return $this->module; |
120
|
|
|
} |
121
|
|
|
|
122
|
|
|
/** |
123
|
|
|
* Sets the exception message |
124
|
|
|
* @param string $exceptionMessage |
125
|
|
|
* @return $this |
126
|
|
|
*/ |
127
|
|
|
public function setExceptionMessage($exceptionMessage) { |
128
|
|
|
$this->exceptionMessage = $exceptionMessage; |
129
|
|
|
return $this; |
130
|
|
|
} |
131
|
|
|
|
132
|
|
|
/** |
133
|
|
|
* Gets the exception message |
134
|
|
|
* @return string |
135
|
|
|
*/ |
136
|
|
|
public function getExceptionMessage() { |
137
|
|
|
return $this->exceptionMessage; |
138
|
|
|
} |
139
|
|
|
|
140
|
|
|
/** |
141
|
|
|
* Set the hierarchy |
142
|
|
|
* @param bool $hierarchy |
143
|
|
|
* @return $this |
144
|
|
|
*/ |
145
|
|
|
public function setHierarchy($hierarchy) { |
146
|
|
|
$this->hierarchical = $hierarchy; |
147
|
|
|
return $this; |
148
|
|
|
} |
149
|
|
|
|
150
|
|
|
/** |
151
|
|
|
* Gets the hierarchy |
152
|
|
|
* @return bool |
153
|
|
|
*/ |
154
|
|
|
public function getHierarchy() { |
155
|
|
|
return $this->hierarchical; |
156
|
|
|
} |
157
|
|
|
} |