Exemplo n.º 1
0
 public function handleAction($action, $params, $raw = false)
 {
     $output = parent::handleAction($action, $params);
     if ($raw || $output instanceof Response) {
         return $output;
     }
     $this->response->setContent($output);
     return $this->response;
 }
Exemplo n.º 2
0
 /**
  * Handle the incoming request.
  * @param $action
  * @param $actionParams
  * @return \b8\b8\Http\Response|Response
  */
 public function handleAction($action, $actionParams)
 {
     $this->setView($action);
     $response = parent::handleAction($action, $actionParams);
     if (is_string($response)) {
         $this->controllerView->content = $response;
     } elseif (isset($this->view)) {
         $this->controllerView->content = $this->view->render();
     }
     $this->response->setContent($this->controllerView->render());
     return $this->response;
 }
Exemplo n.º 3
0
 /** Handle the action, Ensuring to return a JsonResponse.
  *
  * @param string $action
  * @param mixed $actionParams
  *
  * @return \b8\Http\Response
  */
 public function handleAction($action, $actionParams)
 {
     $response = new b8\Http\Response\JsonResponse();
     try {
         $data = parent::handleAction($action, $actionParams);
         if (isset($data['responseCode'])) {
             $response->setResponseCode($data['responseCode']);
             unset($data['responseCode']);
         }
         $response->setContent($data);
     } catch (Exception $ex) {
         $response->setResponseCode(500);
         $response->setContent(array('status' => 'failed', 'error' => $ex->getMessage()));
     }
     return $response;
 }
Exemplo n.º 4
0
 /**
  * Handle the requested action
  *
  * @param $action
  * @param $params
  * @return mixed
  */
 public function handleAction($action, $params)
 {
     try {
         $thisClass = explode('\\', get_class($this));
         $module = $thisClass[1];
         $this->view = Template::getAdminTemplate($this->className . '/' . $action, $module);
         $this->view->currentUser = $this->currentUser;
     } catch (\Exception $ex) {
         $error = '<div class="alert alert-danger">You have not created a view for: ';
         $error .= $this->className . '/' . $action . '</div>';
         $this->view = new Template($error);
     }
     // Set up GlobalMessage:
     if (!empty($this->view)) {
         if (!empty($_SESSION['GlobalMessage']['success'])) {
             $this->view->GlobalMessage()->success = $_SESSION['GlobalMessage']['success'];
             unset($_SESSION['GlobalMessage']['success']);
         }
         if (!empty($_SESSION['GlobalMessage']['error'])) {
             $this->view->GlobalMessage()->error = $_SESSION['GlobalMessage']['error'];
             unset($_SESSION['GlobalMessage']['error']);
         }
         if (!empty($_SESSION['GlobalMessage']['info'])) {
             $this->view->GlobalMessage()->info = $_SESSION['GlobalMessage']['info'];
             unset($_SESSION['GlobalMessage']['info']);
         }
     }
     $output = parent::handleAction($action, $params);
     if (empty($output) && !empty($this->view)) {
         $output = $this->view->render();
     }
     $this->response->setContent($output);
     if ($this->response->hasLayout()) {
         $this->layout->user = $_SESSION['user'];
         $this->layout->content = $this->response->getContent();
         $this->response->setContent($this->layout->render());
     }
     return $this->response;
 }
Exemplo n.º 5
0
 public function handleAction($action, $params)
 {
     $output = parent::handleAction($action, $params);
     $this->response->setContent($output);
     return $this->response;
 }