Example #1
0
 /**
  * Invoke targeted controller's action.
  *
  * @return function
  */
 public function controllerAction()
 {
     $action = $this->request->getAction() . static::ACTION_SUFFIX;
     // check if controller action does exit before invoking action
     if (!method_exists($this, $action)) {
         throw new \RuntimeException(sprintf('Controller action method [%s] not found.', $action), 404);
     }
     return call_user_func_array([$this, $action], []);
 }
Example #2
0
 /**
  * Running application by rendering the output.
  *
  * @return mixed
  */
 public function run()
 {
     // throw page not found exception, if any
     if (!$this->route->isFulfilled()) {
         throw new \Exception('Page not found!', 404);
     }
     // exit if request is via ajax
     // this is to avoid entire view to be re-rendered
     // ajax output can be printed out using standard echo or response
     if ($this->request->isAjax()) {
         return;
     }
     // print out by rendering the output without manually invoking `render` method
     if ($this->getConfig('autoRender') === true) {
         return $this->response->render();
     }
 }