-
Notifications
You must be signed in to change notification settings - Fork 232
/
Copy pathmodule.html
251 lines (237 loc) · 6.59 KB
/
module.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="stylesheet" href="./../assets/css/combined.css?20170912">
<link rel="shortcut icon" href="./../favicon.ico" />
<script src="https://www.google.com/jsapi" type="text/javascript"></script>
<script type="text/javascript">
var path = './../';
var class_prefix = "Module::";
</script>
<script src="./../assets/js/combined.js?20170912"></script>
<title>Module - Classes - FuelPHP Documentation</title>
</head>
<body>
<div id="container">
<header id="header">
<div class="table">
<div id="cse">
<gcse:searchbox-only newWindow="true"></gcse:searchbox-only>
</div>
<h1>
<a href="https://fuelphp.com"><img height="37px" width="147px" src="./../assets/img/fuel.png" /></a>
<strong>Documentation</strong>
</h1>
</div>
<nav>
<div class="clear"></div>
</nav>
<a href="#" id="toc_handle">table of contents</a>
<div class="clear"></div>
</header>
<div id="main">
<h2>Module Class</h2>
<p>The <kbd>Module</kbd> class allows you to easily load, unload, check if a module exists or if it is loaded, or get a list of all modules loaded.</p>
<article>
<h4 class="method" id="method_load">load($module, $path = null)</h4>
<p>The <strong>load</strong> method allows you to load one or more modules at runtime. If the module cannot be found a <kbd>ModuleNotFoundException</kbd> will be thrown.</p>
<table class="method">
<tbody>
<tr>
<th class="legend">Static</th>
<td>Yes</td>
</tr>
<tr>
<th>Parameters</th>
<td>
<table class="parameters">
<tr>
<th>Param</th>
<th>Default</th>
<th class="description">Description</th>
</tr>
<tr>
<th><kbd>$module</kbd></th>
<td><i>required</i></td>
<td>Name of the module to be loaded, or an array of modules.</td>
</tr>
<tr>
<th><kbd>$path</kbd></th>
<td><code>null</code></td>
<td>Path to the given module. You can use this to load modules from outside the defined module paths.</td>
</tr>
</table>
</td>
</tr>
<tr>
<th>Returns</th>
<td><i>void</i></td>
</tr>
<tr>
<th>Example</th>
<td>
<pre class="php"><code>// load a users module
Module::load('users');
// load the users module from a specific directory
Module::load('users', '/path/to/modules/users/');
// load multiple modules from a single module installation
Module::load( array('Users' => '/path/to/modules/users/', 'Groups' => '/path/to/modules/groups/') );
// load the non-existent module
Module::load('awesome'); // Throws a ModuleNotFoundException
</code></pre>
</td>
</tr>
</tbody>
</table>
<p class="note">You can configure whether or not the modules routes should be loaded as well, through the config key "routing.module_routes".</p>
</article>
<article>
<h4 class="method" id="method_unload">unload($module)</h4>
<p>The <strong>unload</strong> method allows you to unload a module at runtime.</p>
<table class="method">
<tbody>
<tr>
<th class="legend">Static</th>
<td>Yes</td>
</tr>
<tr>
<th>Parameters</th>
<td>
<table class="parameters">
<tr>
<th>Param</th>
<th>Default</th>
<th class="description">Description</th>
</tr>
<tr>
<th><kbd>$module</kbd></th>
<td><i>required</i></td>
<td>Name of the module to be unloaded.</td>
</tr>
</table>
</td>
</tr>
<tr>
<th>Returns</th>
<td><i>void</i></td>
</tr>
<tr>
<th>Example</th>
<td>
<pre class="php"><code>// unload the users module
Module::unload('users');
</code></pre>
</td>
</tr>
</tbody>
</table>
<p class="note">This will (attempt to) remove all routes that where defined by the module (in its routes.php file) when it was loaded!</p>
</article>
<article>
<h4 class="method" id="method_loaded">loaded($module = null)</h4>
<p>The <strong>loaded</strong> method allows you to check if a module is currently loaded. If no module name is given then all loaded module are returned.</p>
<table class="method">
<tbody>
<tr>
<th class="legend">Static</th>
<td>Yes</td>
</tr>
<tr>
<th>Parameters</th>
<td>
<table class="parameters">
<tr>
<th>Param</th>
<th>Default</th>
<th class="description">Description</th>
</tr>
<tr>
<th><kbd>$module</kbd></th>
<td><kbd>null</kbd></td>
<td>Name of the module to be checked.</td>
</tr>
</table>
</td>
</tr>
<tr>
<th>Returns</th>
<td><kbd>bool|array</kbd></td>
</tr>
<tr>
<th>Example</th>
<td>
<pre class="php"><code>// Check if the users module is loaded
$loaded = Module::loaded('users');
// Get all loaded modules
$loaded = Module::loaded();
/*
Returns something like:
array(
'users' => '/path/to/users',
'groups' => '/path/to/groups',
)
*/
</code></pre>
</td>
</tr>
</tbody>
</table>
</article>
<article>
<h4 class="method" id="method_exists">exists($module)</h4>
<p>
The <strong>exists</strong> method allows you to check if a module exists, i.e. if it can be found in one of the configured module paths.
If found, it returns the path to the module. If not, it returns <strong>false</strong>.
</p>
<table class="method">
<tbody>
<tr>
<th class="legend">Static</th>
<td>Yes</td>
</tr>
<tr>
<th>Parameters</th>
<td>
<table class="parameters">
<tr>
<th>Param</th>
<th>Default</th>
<th class="description">Description</th>
</tr>
<tr>
<th><kbd>$module</kbd></th>
<td><kbd>null</kbd></td>
<td>Name of the module to be checked.</td>
</tr>
</table>
</td>
</tr>
<tr>
<th>Returns</th>
<td><kbd>bool|string</kbd></td>
</tr>
<tr>
<th>Example</th>
<td>
<pre class="php"><code>// Optionally load the comments module
if (Module::exists('comments'))
{
Module::load('comments');
}
</code></pre>
</td>
</tr>
</tbody>
</table>
</article>
</div>
<footer>
<p>
© FuelPHP Development Team 2010-2018 - <a href="https://fuelphp.com">FuelPHP</a> is released under the MIT license.
</p>
</footer>
</div>
</body>
</html>