Exemplo n.º 1
0
 public function match()
 {
     $uri = null;
     $currentUri = $_SERVER['REQUEST_URI'];
     foreach ($this->routes as $match => $routeargs) {
         if ($currentUri === $match) {
             $uri = $match;
             break;
         }
     }
     if (array_key_exists($uri, $this->routes)) {
         if (ClosureHelper::isClosure($this->routes[$uri])) {
             /* Call if closure */
             echo $this->routes[$uri]();
         } else {
             echo $this->routes[$uri];
         }
     } else {
         if (!isset($this->notFoundRoute)) {
             echo view('404.html');
         } else {
             echo view($this->notFoundRoute);
         }
     }
 }
Exemplo n.º 2
0
 public function bind($key, $value, $singleton = false)
 {
     if (ClosureHelper::isClosure($value)) {
         $this->bindings[$key] = $value();
     } else {
         $this->bindings[$key] = $value;
     }
 }