Пример #1
0
 /**
  * Format response content
  */
 public function after()
 {
     parent::after();
     // If response is an array or format requested is JSON, encode it
     if ($this->request->param('format') == 'json' || is_array($this->_response)) {
         $this->response->headers('Content-Type', 'application/json');
         $this->_response = json_encode($this->_response);
     }
     // Assign to body
     $this->response->body($this->_response);
 }
 /**
  * Define listeners
  */
 protected function listeners()
 {
     parent::listeners();
     Event::listen($this, Event::BEFORE_CREATE, array($this, 'handle_item_before_create'));
     Event::listen($this, Event::BEFORE_UPDATE_FORM_PARSE, array($this, 'handle_item_before_update_form_parse'));
     Event::listen($this, Event::BEFORE_UPDATE, array($this, 'handle_item_before_update'));
     Event::listen($this, Event::AFTER_CREATE, array($this, 'handle_item_after_create'));
     Event::listen($this, Event::AFTER_UPDATE, array($this, 'handle_item_after_update'));
     Event::listen($this, Event::AFTER_DELETE, array($this, 'handle_item_after_delete'));
     Event::listen($this, Event::BEFORE_COPY, array($this, 'handle_item_before_copy'));
     Event::listen($this, Event::AFTER_COPY, array($this, 'handle_item_after_copy'));
 }
Пример #3
0
 /**
  * Generate HTML code from page
  */
 public function after()
 {
     parent::after();
     if ($this->auto_render) {
         // Generate default filename
         if ($this->view->get_filename() === null) {
             $this->view->set_filename($this->find_view());
         }
         // Messages & Errors
         $this->view->set('message', Session::instance()->get_once('message'));
         $this->view->set('errors', Session::instance()->get_once('errors'));
         // Set body
         $this->response->body($this->view);
     }
 }