HookEvent.php 1.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. <?php
  2. namespace Tools;
  3. /**
  4. * Event's parameters
  5. * This classe is attached to a hook when fired
  6. **/
  7. class HookEvent
  8. {
  9. /**
  10. * @var \Tools\Context $context
  11. * /core/tools/Context.php
  12. * Contains website's informations
  13. **/
  14. private $context;
  15. /**
  16. * @var string $hookName
  17. * Contains hook name
  18. * Can be accessed read-only
  19. **/
  20. private $hookName;
  21. /**
  22. * @var mixed params
  23. * Contains parameters that can be passed to the hook when fired
  24. * Can be accessed read-only
  25. **/
  26. private $params;
  27. /**
  28. * Constructor
  29. **/
  30. public function __construct($hookName, $context, $params)
  31. {
  32. $this->context = $context;
  33. $this->hookName = $hookName;
  34. $this->params = $params;
  35. }
  36. /**
  37. * Getter
  38. **/
  39. public function __get($key)
  40. {
  41. switch ($key)
  42. {
  43. case "hookName": return $this->hookName; break;
  44. case "params": return $this->params; break;
  45. }
  46. throw new \Exception("Cannot access attribute {$key}");
  47. }
  48. }