Example #1
0
 /**
  * Execute the middleware controllers on the given route
  *
  * @param array Route
  * @param array Params
  * @return mixed Response
  **/
 public function callRoute(array $route, array $params)
 {
     if (empty($route['handler'])) {
         return null;
     }
     $callback = $route['handler'];
     if (is_a($callback, 'Closure')) {
         return $this->container->fireMethod($callback, null, $params);
     } elseif (strpos($callback, '@') !== false) {
         return $this->container->makeMethod($callback, $params);
     } elseif (is_callable($callback)) {
         return empty($params) ? call_user_func($callback) : call_user_func_array($callback, $params);
     }
     throw new RuntimeException('Unable to execute route handler');
 }