| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758 |
- <?php
- namespace Tools;
- /**
- * Allow user to manage hooks
- **/
- class Hooks
- {
- /**
- * @var \Tools\Context $context
- * /core/tools/Context.php
- * Contains website's informations
- **/
- private $context;
- /**
- * ctor. Initialize context for having them passed to hook as parameter
- **/
- public function __construct($context)
- {
- $this->context = $context;
- }
- /**
- * @param \Tool\AModule $module
- * @param string $hookname
- * Attach module $module to $hookName
- * Can only be called while installing the module.
- * When fired, the AModule::doAction($hookName, $context) function will be called.
- **/
- public function register($module, $hookName)
- {
- if (!\Tools\ModuleManager::isInstalling())
- throw new \Exception("You can only register hooks while installing");
- //TODO@2
- }
- /**
- * @param string $hookName
- * fire the hook hookName
- * call the AModule::doAction($hookName, $context) function for each attached modules
- **/
- public function trigger($hookName)
- {
- echo "Triggering hook `{$hookName}'";
- //TODO@2
- }
- /**
- * @param array(\Entity\ModuleHook) $module_hookEntities entities to load
- * Reload hooks from entities
- **/
- public function loadHooks($hookEntities)
- {
- }
- }
|