ecom
E-commerce cms
 All Data Structures Namespaces Files Functions Variables Pages
Context.php
Go to the documentation of this file.
1 <?php
2 
3 namespace Tools;
4 
10 class Context
11 {
18  private $hookManager;
19 
26  private $moduleManager;
27 
35  private $router;
36 
44  private $cart;
45 
52  private $user;
53 
59  private $controller;
60 
65  public function __construct()
66  {
67  $this->hookManager = new Hooks($this);
68  $this->router = new Router($this);
69  if (!\Entity\ModelBase::init())
70  {
71  @require_once(getcwd().'/core/setup/index.php');
72  die;
73  }
74  $this->router->init();
75  $this->moduleManager = new ModuleManager($this);
76  $this->hookManager->trigger("routerSetup");
77  try
78  {
79  $this->controller = $this->router->serveUrl();
80  if (!$this->controller)
81  throw new \Exception\Error404();
82  $this->controller->start();
83  }
84  catch (\Exception\Error404 $e)
85  {
86  echo "404";
87  }
88  }
89 
93  public function __get($key)
94  {
95  switch ($key)
96  {
97  case "router": return $this->router; break;
98  case "cart": return $this->cart; break;
99  case "user": return $this->user; break;
100  case "moduleManager": return $this->moduleManager; break;
101  case "hookManager": return $this->hookManager; break;
102  }
103  throw new \Exception("Cannot access attribute {$key}");
104  }
105 }
106 
__get($key)
Definition: Context.php:93