| Conditions | 6 |
| Paths | 5 |
| Total Lines | 26 |
| Code Lines | 11 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 0 | ||
| 1 | <?php |
||
| 30 | public static function create($module, Array $module_settings = []) |
||
| 31 | { |
||
| 32 | if (empty($module)) |
||
| 33 | throw new \RuntimeException("The module name must be specified"); |
||
| 34 | |||
| 35 | if (!is_string($module)) |
||
|
|
|||
| 36 | throw new \InvalidArgumentException("Invalid type given. string expected"); |
||
| 37 | |||
| 38 | /* |
||
| 39 | * Module class instantiation |
||
| 40 | * |
||
| 41 | * Each module must have a class called Module in her namespace. This class |
||
| 42 | * is initilized here and can change the behavior of a controller using |
||
| 43 | * allowExecution() or disallowExecution(). |
||
| 44 | */ |
||
| 45 | $fqn_module = "\\" . $module . "\\Module"; |
||
| 46 | |||
| 47 | if (!class_exists($fqn_module)) |
||
| 48 | throw new Exception\ModuleNotFoundException("The module class '$fqn_module' does not exists!"); |
||
| 49 | |||
| 50 | $module = new $fqn_module($module); |
||
| 51 | |||
| 52 | if (array_key_exists('config', $module_settings) && !is_null($module_settings["config"])) |
||
| 53 | $module->setConfigFile($module_settings["config"]); |
||
| 54 | |||
| 55 | return $module; |
||
| 56 | } |
||
| 57 | } |