public function before() { parent::before(); $param = $this->request->param(); // Set the input property $this->_input = (array) json_decode($this->request->body(), TRUE); // Set the model using the id parameter (and the id attribute if that is not given) $this->group = str_replace('/', '.', $this->request->param('id', Arr::get($this->_input, 'id'))); }
public function before() { parent::before(); $param = $this->request->param(); // Set the input property $this->_input = (array) json_decode($this->request->body(), TRUE); // Set the model using the id parameter (and the id attribute if that is not given) /* $this->user = ORM::factory('user', $this->request->param('id', Arr::get($this->_input, 'id'))); */ }
public function before() { parent::before(); $param = $this->request->param(); // Extract the time // Time (year is a unix timestamp) if (!empty($param['year'])) { $this->time = gmmktime(0, 0, 0, Arr::get($param, 'month', 1), Arr::get($param, 'day', 1), Arr::get($param, 'year')); } // Set the input property $this->_input = (array) json_decode($this->request->body(), TRUE); // Set the model using the id parameter (and the id attribute if that is not given) $this->chart = ORM::factory('chart', $this->request->param('id', Arr::get($this->_input, 'id'))); Kohana::$log->add(Log::INFO, $this->request->action()); }
public function before() { parent::before(); $format = Arr::get($_GET, 'format'); if (empty($format)) { $parts = explode(".", $this->request->uri); if (!empty($parts[1])) { $format = $parts[1]; } } switch ($format) { case 'jsn': case 'json': $this->driver = API::driver('json'); break; case 'xml': default: $this->driver = API::driver('xml'); break; } }
public function before() { $pbefore = parent::before(); if (Request::$method === 'POST') { $this->request->posted_content_type = $this->_req_content_type(); $this->request->posted_raw = file_get_contents('php://input'); $this->request->posted_data = $this->_unserialize($this->request->posted_raw); } elseif (Request::$method === 'PUT') { $this->request->put_content_type = $this->_req_content_type(); $this->request->put_raw = Request::$raw_req_body; $this->request->put_data = $this->_unserialize($this->request->put_raw); } else { if (isset($_GET['f'])) { $this->_format = $_GET['f']; } elseif ($this->request->param('format')) { $this->_format = $this->request->param('format'); } else { $this->_format = $this->_default_format; } if ($this->_format === 'jsonp') { if (isset($_GET['callback']) && preg_match('/^[\\w\\.]+$/', $_GET['callback'])) { $this->_jsonp_callback = $_GET['callback']; } } } try { $this->_auth_current_user(); } catch (Exception $e) { $this->_forbidden($e->getMessage()); $this->after(); $this->request->send_headers(); print $this->request->response; die; } return $pbefore; }