Context.php 1.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. <?php
  2. namespace Tools;
  3. class Context
  4. {
  5. private $hookManager;
  6. private $moduleManager;
  7. private $router;
  8. private $cart;
  9. private $user;
  10. public function __construct()
  11. {
  12. $this->hookManager = new Hooks($this);
  13. $this->router = new Router();
  14. if (!\Entity\ModelBase::init())
  15. {
  16. @require_once(getcwd().'/core/setup/index.php');
  17. die;
  18. }
  19. $this->router->init();
  20. $this->moduleManager = new ModuleManager($this);
  21. $this->hookManager->trigger("routerSetup");
  22. $this->router->serveUrl();
  23. }
  24. public function __get($key)
  25. {
  26. switch ($key)
  27. {
  28. case "router": return $this->router; break;
  29. case "cart": return $this->cart; break;
  30. case "user": return $this->user; break;
  31. case "moduleManager": return $this->moduleManager; break;
  32. case "hookManager": return $this->hookManager; break;
  33. }
  34. throw new \Exception("Cannot access attribute {$key}");
  35. }
  36. }