KXStudio Website https://kx.studio/
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

40 lines
1.4KB

  1. <?php
  2. /**
  3. * Class: Modules
  4. * Contains various functions, acts as the backbone for all modules.
  5. */
  6. class Modules {
  7. # Array: $instances
  8. # Holds all Module instantiations.
  9. static $instances = array();
  10. # Boolean: $cancelled
  11. # Is the module's execution cancelled?
  12. public $cancelled = false;
  13. /**
  14. * Function: setPriority
  15. * Sets the priority of an action for the module this function is called from.
  16. *
  17. * Parameters:
  18. * $name - Name of the trigger to respond to.
  19. * $priority - Priority of the response.
  20. */
  21. protected function setPriority($name, $priority) {
  22. Trigger::current()->priorities[$name][] = array("priority" => $priority, "function" => array($this, $name));
  23. }
  24. /**
  25. * Function: addAlias
  26. * Allows a module to respond to a trigger with multiple functions and custom priorities.
  27. *
  28. * Parameters:
  29. * $name - Name of the trigger to respond to.
  30. * $function - Name of the class function to respond with.
  31. * $priority - Priority of the response.
  32. */
  33. protected function addAlias($name, $function, $priority = 10) {
  34. Trigger::current()->priorities[$name][] = array("priority" => $priority, "function" => array($this, $function));
  35. }
  36. }