1 | <?php |
||
11 | class Module |
||
12 | { |
||
13 | /** |
||
14 | * @var string $pathName Module's name |
||
15 | */ |
||
16 | protected $pathName = ''; |
||
17 | |||
18 | /** |
||
19 | * @var \BFW\Config $config Config object for this module |
||
20 | */ |
||
21 | protected $config; |
||
22 | |||
23 | /** |
||
24 | * @var \stdClass $loadInfos All informations about the module running |
||
25 | */ |
||
26 | protected $loadInfos; |
||
27 | |||
28 | /** |
||
29 | * |
||
30 | * @var \stdClass $status Load and run status |
||
31 | */ |
||
32 | protected $status; |
||
33 | |||
34 | /** |
||
35 | * Constructor |
||
36 | * Load all informations if $loadModule is true |
||
37 | * |
||
38 | * @param string $pathName Module name |
||
39 | * @param boolean $loadModule (default true) If run load information |
||
40 | */ |
||
41 | public function __construct($pathName, $loadModule = true) |
||
49 | |||
50 | /** |
||
51 | * Load informations about the module |
||
52 | * |
||
53 | * @return void |
||
54 | */ |
||
55 | public function loadModule() |
||
66 | |||
67 | /** |
||
68 | * Get installation informations |
||
69 | * |
||
70 | * @param string $sourceFiles Path to module source (in vendor) |
||
71 | * |
||
72 | * @return \stdClass |
||
73 | */ |
||
74 | public static function installInfos($sourceFiles) |
||
79 | |||
80 | /** |
||
81 | * Get the module's name |
||
82 | * |
||
83 | * @return string |
||
84 | */ |
||
85 | public function getPathName() |
||
89 | |||
90 | /** |
||
91 | * Get the Config object which have config for this module |
||
92 | * |
||
93 | * @return \BFW\Config |
||
94 | */ |
||
95 | public function getConfig() |
||
99 | |||
100 | /** |
||
101 | * Get the load informations |
||
102 | * |
||
103 | * @return \stdClass |
||
104 | */ |
||
105 | public function getLoadInfos() |
||
109 | |||
110 | /** |
||
111 | * Get the status object for this module |
||
112 | * |
||
113 | * @return \stdClass |
||
114 | */ |
||
115 | public function getStatus() |
||
119 | |||
120 | /** |
||
121 | * Return the load status |
||
122 | * |
||
123 | * @return boolean |
||
124 | */ |
||
125 | public function isLoaded() |
||
129 | |||
130 | /** |
||
131 | * Return the run status |
||
132 | * |
||
133 | * @return boolean |
||
134 | */ |
||
135 | public function isRun() |
||
139 | |||
140 | /** |
||
141 | * Instantiate the Config object to obtains module's configuration |
||
142 | * |
||
143 | * @return void |
||
144 | */ |
||
145 | public function loadConfig() |
||
154 | |||
155 | /** |
||
156 | * Get load information from json file |
||
157 | * |
||
158 | * @return void |
||
159 | */ |
||
160 | public function loadModuleInfos() |
||
169 | |||
170 | /** |
||
171 | * Read a json file and return datas in json |
||
172 | * |
||
173 | * @param string $jsonFilePath : The path to the file to read |
||
174 | * |
||
175 | * @return mixed Json parsed datas |
||
176 | * |
||
177 | * @throws Exception If the file is not found or for a json parser error |
||
178 | */ |
||
179 | protected static function loadJsonFile($jsonFilePath) |
||
192 | |||
193 | /** |
||
194 | * Add a dependency to module |
||
195 | * Used by needMe property in module infos |
||
196 | * |
||
197 | * @param string $dependencyName The dependency name to add |
||
198 | * |
||
199 | * @return $this |
||
200 | */ |
||
201 | public function addDependency($dependencyName) |
||
215 | |||
216 | /** |
||
217 | * Get path to the runner file |
||
218 | * |
||
219 | * @return string |
||
220 | * |
||
221 | * @throws Exception If the file not exists |
||
222 | */ |
||
223 | protected function getRunnerFile() |
||
248 | |||
249 | /** |
||
250 | * Run the module in a closure |
||
251 | * |
||
252 | * @return void |
||
253 | */ |
||
254 | public function runModule() |
||
270 | } |
||
271 |