public function __construct()
 {
     self::$__instance = $this;
     set_exception_handler('exceptionHandler');
     // setup our loader instance
     $this->loader = new Loader();
     // load a few helpers
     $this->loader->helper('uri', FRAMEWORK_PATH . 'helpers');
     // loader the plugins
     $this->plugins = $this->loader->manager('plugins');
     $this->plugins->loadFrameworkPlugins();
     // what shall we load first?
     $this->route = $this->loader->manager('route')->find();
     // load the controller
     $this->controller = $this->loader->controller($this->route->getController());
     $this->controller->invokeAction($this->route->getAction());
 }
Example #2
0
 /**
  * invokes the controllers action via the invokeAction method in the controller class
  * @param  Controller $controller current controller
  * @return Response                 response object created by the controller
  */
 protected function _invoke(Controller $controller)
 {
     $response = $controller->invokeAction();
     if (!$response && $controller->autorender) {
         $response = $controller->render();
     } else {
         $response = $controller->response->send();
     }
     return $response;
 }
 /**
 * Initializes the components and models a controller will be using.
 * Triggers the controller action, and invokes the rendering if Controller::$autoRender is true and echo's the output.
 * Otherwise the return value of the controller action are returned.
 *
 * Works like {@see Dispatcher::_invoke()} but returns the full response instead the body only.
 *
 * Bancha needs to overwrite this method because we need the full response object not only the body of the response
 * object on return.
 *
 * @param Controller $controller Controller to invoke
 * @param CakeRequest $request The request object to invoke the controller for.
 * @param CakeResponse $response The response object to receive the output
 * @return CakeResponse te resulting response object
 */
 protected function _invoke(Controller $controller, CakeRequest $request, CakeResponse $response)
 {
     $controller->constructClasses();
     $controller->startupProcess();
     $render = true;
     $result = $controller->invokeAction($request);
     if ($result instanceof CakeResponse) {
         $render = false;
         $response = $result;
     }
     if ($render && $controller->autoRender) {
         $response = $controller->render();
     } elseif ($response->body() === null) {
         $response->body($result);
     }
     $controller->shutdownProcess();
     if (isset($request->params['return'])) {
         return $response;
         // <-------------- only this line is changed, original: return $response->body();
     }
     $response->send();
 }
 /**
  * Initializes the components and models a controller will be using.
  * Triggers the controller action, and invokes the rendering if Controller::$autoRender is true and echo's the output.
  * Otherwise the return value of the controller action are returned.
  *
  * @param Controller $controller Controller to invoke
  * @param CakeRequest $request The request object to invoke the controller for.
  * @param CakeResponse $response The response object to receive the output
  * @return CakeResponse the resulting response object
  */
 protected function _invoke(Controller $controller, CakeRequest $request, CakeResponse $response)
 {
     $controller->constructClasses();
     $controller->startupProcess();
     $render = true;
     $result = $controller->invokeAction($request);
     if ($result instanceof CakeResponse) {
         $render = false;
         $response = $result;
     }
     if ($render && $controller->autoRender) {
         $response = $controller->render();
     } elseif (!$result instanceof CakeResponse && $response->body() === null) {
         $response->body($result);
     }
     $controller->shutdownProcess();
     return $response;
 }
 /**
  * Allows extending action from component
  *
  * @throws MissingActionException
  */
 public function invokeAction(CakeRequest $request)
 {
     try {
         return parent::invokeAction($request);
     } catch (MissingActionException $e) {
         $params = $request->params;
         $prefix = isset($params['prefix']) ? $params['prefix'] : '';
         $action = str_replace($prefix . '_', '', $params['action']);
         foreach ($this->_apiComponents as $component => $setting) {
             if (empty($this->{$component})) {
                 continue;
             }
             if ($this->{$component}->isValidAction($action)) {
                 $this->setRequest($request);
                 return $this->{$component}->{$action}($this);
             }
         }
         throw $e;
     }
 }
Example #6
0
 /**
  * Dispatches the controller action.  Checks that the action
  * exists and isn't private.
  *
  * @throws PrivateActionException, MissingActionException
  *
  * @param CakeRequest $request the current request
  *
  * @return mixed The resulting response.
  */
 public function invokeAction(CakeRequest $request)
 {
     try {
         parent::invokeAction($request);
     } catch (MissingActionException $e) {
         return $this->invokeComponentAction($request, $e);
     }
 }
Example #7
0
 /**
  * Método que se encarga de invocar a la acción del controlador y
  * entregar la respuesta
  * @author Esteban De La Fuente Rubio, DeLaF (esteban[at]delaf.cl)
  * @version 2014-03-22
  */
 private static function _invoke(Controller $controller, Network_Request $request, Network_Response $response)
 {
     // Iniciar el proceso
     $controller->startupProcess();
     // Ejecutar acción
     $result = $controller->invokeAction();
     // Renderizar proceso
     if ($controller->autoRender) {
         $response = $controller->render();
     } elseif ($response->body() === null) {
         $response->body($result);
     }
     // Detener el proceso
     $controller->shutdownProcess();
     // Retornar respuesta al cliente
     if (isset($request->params['return'])) {
         return $response->body();
     }
     // Enviar respuesta al cliente
     $response->send();
 }