Conditions | 3 |
Paths | 4 |
Total Lines | 31 |
Code Lines | 14 |
Lines | 0 |
Ratio | 0 % |
Changes | 0 |
1 | <?php |
||
23 | final public function displayModuleContent($method, $args) |
||
24 | { |
||
25 | // if method not callbale abort to 'not found' |
||
26 | if (! is_callable([$this, $method])) abort(404); |
||
27 | |||
28 | // if user has no access abort 'no access' |
||
29 | if (! $this->access()) abort(401); |
||
30 | |||
31 | $args = $this->decodeArgs($args); |
||
32 | |||
33 | // filter for entries with numeric keys use values as method arguments |
||
34 | $argsNumeric = array_filter($args, function($key) { |
||
35 | return is_numeric($key); |
||
36 | }, ARRAY_FILTER_USE_KEY); |
||
37 | |||
38 | $argsAssoc = array_diff_key($args, $argsNumeric); |
||
39 | |||
40 | // set the associative array keys as view properties |
||
41 | $this->setDefaults($argsAssoc); |
||
42 | |||
43 | ksort($argsNumeric); |
||
44 | |||
45 | // method can add seeds to the module seed |
||
46 | // the content echoed in the method is assigned to the module view content region |
||
47 | ob_start(); |
||
48 | $this->{$method}(...$argsNumeric); |
||
49 | $content = ob_get_clean(); |
||
50 | |||
51 | $this->set('Content', $content); |
||
52 | |||
53 | return $this; |
||
54 | } |
||
56 |