Example #1
0
 public function callAction($method, $parameters)
 {
     $response = parent::callAction($method, $parameters);
     if (gettype($response) == 'object') {
         if (method_exists($response, 'toArray')) {
             $response = $response->toArray();
         } else {
             return $response;
         }
     }
     $fields = explode(',', \Input::get('fields'));
     if ($fields[0]) {
         $response = $this->filterResponse($fields, $response);
     }
     $callback = \Input::get('callback');
     if (!$callback) {
         $json = json_encode($response, JSON_PRETTY_PRINT);
         return \Response::make($json)->header('Content-Type', "application/json");
     } else {
         $data = [];
         $data['status_code'] = 200;
         $data['response'] = $response;
         return \Response::json($data)->setCallback($callback);
     }
 }
Example #2
0
 /**
  * {@inheritdoc}
  */
 public function callAction($action = null)
 {
     $response = parent::callAction($action);
     if (!$response->isRedirection() && !$response->isNotFound() && !$this->getRequest()->isXmlHttpRequest()) {
         $this->saveURL();
     }
     return $response;
 }
Example #3
0
 /**
  * {@inheritdoc}
  */
 public function callAction($action = null)
 {
     try {
         return parent::callAction($action);
     } catch (HTTPException $e) {
         return new Response($e->getMessage());
     } catch (Exception $e) {
         // Let PHP handle the exception on the dev environment
         if ($this->isDebug()) {
             throw $e;
         }
         return new Response("An error occured");
     }
 }
 protected final function callAction(Controller $controller, $action_name, array $args, $api_call)
 {
     $controller->setRequestData($args);
     $controller->callAction($api_call ? 'API' : App::i()->request()->getMethod(), $action_name, $args);
 }
 protected final function callAction(Controller $controller, $action_name, array $args, $api_call)
 {
     $controller->setRequestData($args);
     if ($api_call && !$controller->usesAPI()) {
         App::i()->pass();
     } else {
         $controller->callAction($api_call ? 'API' : App::i()->request()->getMethod(), $action_name, $args);
     }
 }