1 | <?php |
||
27 | class RootModuleFile extends ModuleFile |
||
28 | { |
||
29 | /** |
||
30 | * @var Config |
||
31 | */ |
||
32 | private $config; |
||
33 | |||
34 | /** |
||
35 | * @var string[] |
||
36 | */ |
||
37 | private $moduleOrder = array(); |
||
38 | |||
39 | /** |
||
40 | * @var InstallInfo[] |
||
41 | */ |
||
42 | private $installInfos = array(); |
||
43 | |||
44 | /** |
||
45 | * @var string[] |
||
46 | */ |
||
47 | private $pluginClasses = array(); |
||
48 | |||
49 | /** |
||
50 | * Creates a new root module file. |
||
51 | * |
||
52 | * The file's configuration will inherit its settings from the base |
||
53 | * configuration passed to the constructor. |
||
54 | * |
||
55 | * @param string|null $moduleName The module name. Optional. |
||
56 | * @param string|null $path The path where the configuration is |
||
57 | * stored or `null` if this configuration is |
||
58 | * not stored on the file system. |
||
59 | * @param Config|null $baseConfig The configuration that the module will |
||
60 | * inherit its configuration values from. |
||
61 | */ |
||
62 | 498 | public function __construct($moduleName = null, $path = null, Config $baseConfig = null) |
|
68 | |||
69 | /** |
||
70 | * Returns the configuration of the module. |
||
71 | * |
||
72 | * @return Config The configuration. |
||
73 | */ |
||
74 | 340 | public function getConfig() |
|
78 | |||
79 | /** |
||
80 | * Returns the order in which modules should be loaded. |
||
81 | * |
||
82 | * If modules contain path mappings for the same resource paths, this |
||
83 | * setting can be used to specify in which order these modules should be |
||
84 | * loaded. Alternatively, you can use {@link setOverriddenModules()} to |
||
85 | * mark one of the modules to override the other one. |
||
86 | * |
||
87 | * @return string[] A list of module names. |
||
88 | */ |
||
89 | 81 | public function getModuleOrder() |
|
90 | { |
||
91 | 81 | return $this->moduleOrder; |
|
92 | } |
||
93 | |||
94 | /** |
||
95 | * Sets the order in which modules should be loaded. |
||
96 | * |
||
97 | * If modules contain path mappings for the same resource paths, this |
||
98 | * setting can be used to specify in which order these modules should be |
||
99 | * loaded. Alternatively, you can use {@link setOverriddenModules()} to |
||
100 | * mark one of the modules to override the other one. |
||
101 | * |
||
102 | * @param string[] $moduleOrder A list of module names. |
||
103 | */ |
||
104 | 4 | public function setModuleOrder(array $moduleOrder) |
|
105 | { |
||
106 | 4 | $this->moduleOrder = $moduleOrder; |
|
107 | 4 | } |
|
108 | |||
109 | /** |
||
110 | * Sets the install infos of all installed modules. |
||
111 | * |
||
112 | * @param InstallInfo[] The install infos. |
||
113 | */ |
||
114 | 2 | public function setInstallInfos(array $installInfos) |
|
122 | |||
123 | /** |
||
124 | * Adds install info for an installed module. |
||
125 | * |
||
126 | * @param InstallInfo $installInfo The install info. |
||
127 | */ |
||
128 | 172 | public function addInstallInfo(InstallInfo $installInfo) |
|
132 | |||
133 | /** |
||
134 | * Removes the install info of an installed module. |
||
135 | * |
||
136 | * @param string $moduleName The module name. |
||
137 | */ |
||
138 | 10 | public function removeInstallInfo($moduleName) |
|
142 | |||
143 | /** |
||
144 | * Removes all install infos. |
||
145 | */ |
||
146 | 1 | public function clearInstallInfos() |
|
150 | |||
151 | /** |
||
152 | * Returns the install info of an installed module. |
||
153 | * |
||
154 | * @param string $moduleName The module name. |
||
155 | * |
||
156 | * @return InstallInfo The install info. |
||
157 | * |
||
158 | * @throws NoSuchModuleException If no module is installed with that name. |
||
159 | */ |
||
160 | 9 | public function getInstallInfo($moduleName) |
|
171 | |||
172 | /** |
||
173 | * Returns the install infos of all installed modules. |
||
174 | * |
||
175 | * @return InstallInfo[] The install infos. |
||
176 | */ |
||
177 | 66 | public function getInstallInfos() |
|
182 | |||
183 | /** |
||
184 | * Returns whether an install info with a given name exists. |
||
185 | * |
||
186 | * @param string $moduleName The name of the module. |
||
187 | * |
||
188 | * @return bool Whether install info with that name exists. |
||
189 | */ |
||
190 | 10 | public function hasInstallInfo($moduleName) |
|
194 | |||
195 | /** |
||
196 | * Returns whether the module file contains any install infos. |
||
197 | * |
||
198 | * @return bool Returns `true` if the file contains install infos and |
||
199 | * `false` otherwise. |
||
200 | */ |
||
201 | 2 | public function hasInstallInfos() |
|
205 | |||
206 | /** |
||
207 | * Returns the plugin classes. |
||
208 | * |
||
209 | * @return string[] The fully qualified plugin class names. |
||
|
|||
210 | * |
||
211 | * @see setPluginClasses() |
||
212 | */ |
||
213 | 57 | public function getPluginClasses() |
|
217 | |||
218 | /** |
||
219 | * Sets the plugin classes. |
||
220 | * |
||
221 | * The plugin classes must be fully-qualified class names that implement |
||
222 | * {@link Puli\Manager\Api\PuliPlugin}. If a class is not |
||
223 | * found or does not implement that interface, an exception is thrown. |
||
224 | * |
||
225 | * The plugin classes must not have required parameters in their constructor |
||
226 | * so that they can be successfully instantiated. If a constructor has |
||
227 | * required parameters, an exception is thrown. |
||
228 | * |
||
229 | * Leading backslashes are removed from the fully-qualified class names. |
||
230 | * |
||
231 | * @param string[] $pluginClasses The fully qualified plugin class names. |
||
232 | * |
||
233 | * @throws InvalidConfigException If the class is not found, is not a class, |
||
234 | * does not implement {@link PuliPlugin} |
||
235 | * or has required constructor parameters. |
||
236 | */ |
||
237 | 36 | public function setPluginClasses(array $pluginClasses) |
|
243 | |||
244 | /** |
||
245 | * Adds multiple plugin classes. |
||
246 | * |
||
247 | * The plugin classes must be fully-qualified class names that implement |
||
248 | * {@link Puli\Manager\Api\PuliPlugin}. If a class is not |
||
249 | * found or does not implement that interface, an exception is thrown. |
||
250 | * |
||
251 | * The plugin classes must not have required parameters in their constructor |
||
252 | * so that they can be successfully instantiated. If a constructor has |
||
253 | * required parameters, an exception is thrown. |
||
254 | * |
||
255 | * Leading backslashes are removed from the fully-qualified class names. |
||
256 | * |
||
257 | * @param string[] $pluginClasses The fully qualified plugin class names. |
||
258 | */ |
||
259 | 37 | public function addPluginClasses(array $pluginClasses) |
|
265 | |||
266 | /** |
||
267 | * Adds a plugin class. |
||
268 | * |
||
269 | * The plugin class must be a fully-qualified class name that implements |
||
270 | * {@link PuliPlugin}. If the class is not found or does not implement |
||
271 | * that interface, an exception is thrown. |
||
272 | * |
||
273 | * The plugin class must not have required parameters in its constructor |
||
274 | * so that it can be successfully instantiate. If the constructor has |
||
275 | * required parameters, an exception is thrown. |
||
276 | * |
||
277 | * Leading backslashes are removed from the fully-qualified class name. |
||
278 | * |
||
279 | * @param string $pluginClass The fully qualified plugin class name. |
||
280 | */ |
||
281 | 57 | public function addPluginClass($pluginClass) |
|
285 | |||
286 | /** |
||
287 | * Removes a plugin class. |
||
288 | * |
||
289 | * If the plugin class has not been added, this method does nothing. This |
||
290 | * method also does not validate whether the passed value is actually a |
||
291 | * plugin class. |
||
292 | * |
||
293 | * Leading backslashes are removed from the fully-qualified class name. |
||
294 | * |
||
295 | * @param string $pluginClass The fully qualified plugin class name. |
||
296 | */ |
||
297 | 10 | public function removePluginClass($pluginClass) |
|
301 | |||
302 | /** |
||
303 | * Removes all plugin classes. |
||
304 | */ |
||
305 | 1 | public function clearPluginClasses() |
|
309 | |||
310 | /** |
||
311 | * Returns whether the configuration contains a plugin class. |
||
312 | * |
||
313 | * @param string $pluginClass The fully qualified plugin class name. |
||
314 | * |
||
315 | * @return bool Whether the configuration contains the plugin class. |
||
316 | */ |
||
317 | 14 | public function hasPluginClass($pluginClass) |
|
321 | |||
322 | /** |
||
323 | * Returns whether the configuration contains any plugin classes. |
||
324 | * |
||
325 | * @return bool Whether the configuration contains any plugin classes. |
||
326 | */ |
||
327 | 2 | public function hasPluginClasses() |
|
331 | } |
||
332 |
This check compares the return type specified in the
@return
annotation of a function or method doc comment with the types returned by the function and raises an issue if they mismatch.