Example #1
0
/**
 * include and run given route 
 *
 * @param Route   $route   the route to be loaded
 * @param Request $request the request datas
 *
 * @return string the produced HTML to render
 *
 * @access public
 */
function load(Route $route, Request $request)
{
    $location = explode('::', $route->getLocation());
    include_once $location[0] . '/init.php';
    $request->addParams($route->getOptions());
    return call_user_func($location[1], $request);
}
Example #2
0
 /**
  * instantiate controller object and trigger it's action method
  *
  * @param  string $controller
  * @param  string $method
  * @param  array  $args
  */
 private function triggerController($controller, $method = "index", $args = [])
 {
     $this->request->addParams(['controller' => $controller, 'action' => $method, 'args' => $args]);
     $this->controller = new $controller($this->request, $this->response);
     if (!empty($args)) {
         call_user_func_array([$this->controller, $method], $args);
     } else {
         $this->controller->{$method}();
     }
 }
Example #3
0
 /**
  * instantiate controller object and trigger it's action method
  *
  * @param  string $controller
  * @param  string $method
  * @param  array  $args
  * @return Response 
  */
 private function invoke($controller, $method = "index", $args = [])
 {
     $this->request->addParams(['controller' => $controller, 'action' => $method, 'args' => $args]);
     $this->controller = new $controller($this->request, $this->response);
     $result = $this->controller->startupProcess();
     if ($result instanceof Response) {
         return $result->send();
     }
     if (!empty($args)) {
         $response = call_user_func_array([$this->controller, $method], $args);
     } else {
         $response = $this->controller->{$method}();
     }
     if ($response instanceof Response) {
         return $response->send();
     }
     return $this->response->send();
 }