Code Coverage |
||||||||||
Classes and Traits |
Functions and Methods |
Lines |
||||||||
| Total | |
0.00% |
0 / 1 |
|
57.14% |
4 / 7 |
CRAP | |
71.43% |
10 / 14 |
| AModule | |
0.00% |
0 / 1 |
|
70.00% |
7 / 10 |
18.57 | |
71.43% |
10 / 14 |
| install | |
100.00% |
1 / 1 |
1 | ||||||
| uninstall | |
0.00% |
0 / 1 |
2 | |
0.00% |
0 / 1 |
|||
| doAction | |
100.00% |
1 / 1 |
1 | ||||||
| doShortCode | |
100.00% |
1 / 1 |
1 | ||||||
| setContext | |
100.00% |
1 / 1 |
2 | |
100.00% |
3 / 3 |
|||
| setEntity | |
100.00% |
1 / 1 |
2 | |
100.00% |
3 / 3 |
|||
| registerHook | |
0.00% |
0 / 1 |
2 | |
0.00% |
0 / 2 |
|||
| getName | |
100.00% |
1 / 1 |
1 | |
100.00% |
1 / 1 |
|||
| getDescription | |
0.00% |
0 / 1 |
2 | |
0.00% |
0 / 1 |
|||
| __get | |
100.00% |
1 / 1 |
3 | |
100.00% |
3 / 3 |
|||
| <?php | |
| namespace Tools; | |
| /** | |
| * Module superclass | |
| * Contains all informations about the module | |
| **/ | |
| abstract class AModule | |
| { | |
| /** | |
| * @var \Tools\Context $context | |
| * /core/tools/Context.php | |
| * Website context | |
| * Can be accessed read-only | |
| **/ | |
| private $context; | |
| /** | |
| * @var Module database object | |
| **/ | |
| private $entity; | |
| /** | |
| * Called on module install | |
| * Should register shortcodes and Hooks | |
| **/ | |
| public abstract function install(); | |
| /** | |
| * Called on module unsinstall | |
| **/ | |
| public function uninstall() | |
| { } | |
| /** | |
| * @param \Tools\HookEvent $event called hook | |
| * /core/tools/HookEvent.php | |
| * Called on hook reception | |
| **/ | |
| public abstract function doAction($event); | |
| /** | |
| * @param string $shortCode | |
| * @param array ( key => value ) shortcode's parameters | |
| * Called on shortcode reception | |
| **/ | |
| public abstract function doShortCode($shortCode, $params); | |
| /** | |
| * @param \Tools\Context $context | |
| * /core/tools/Context.php | |
| * set the application context | |
| * Will work only one time | |
| **/ | |
| public function setContext($context) | |
| { | |
| if ($this->context === null) | |
| $this->context = $context; | |
| } | |
| /** | |
| * @param \Entity\Module $module | |
| * /core/models/Module.php | |
| * set the module database object | |
| * Will work only one time | |
| **/ | |
| public function setEntity($entity) | |
| { | |
| if ($this->entity === null) | |
| $this->entity = $entity; | |
| } | |
| /** | |
| * Register hook to be triggered | |
| * Can only be triggered while module setup | |
| **/ | |
| public static function registerHook($hookName) | |
| { | |
| $this->context->hooks->register($this, $hookname); | |
| } | |
| /** | |
| * @return string module name | |
| **/ | |
| public function getName() | |
| { | |
| return $this->entity->name; | |
| } | |
| /** | |
| * @return string module's description | |
| **/ | |
| public function getDescription() | |
| { return ""; } | |
| /** | |
| * Getter | |
| **/ | |
| public function __get($key) | |
| { | |
| switch ($key) | |
| { | |
| case "context": return $this->context; break; | |
| case "entity": return $this->entity; break; | |
| } | |
| throw new \Exception("Cannot access attribute {$key}"); | |
| } | |
| } | |