/** * Set a request property * * This function translates 'limitstart' to 'offset' for compatibility with Joomla * * @param string The property name. * @param mixed The property value. */ public function __set($property, $value) { if ($property == 'limitstart') { $property = 'offset'; } parent::__set($property, $value); }
/** * Supports a simple form Fluent Interfaces. Allows you to set the request * properties by using the request property name as the method name. * * For example : $controller->view('name')->limit(10)->browse(); * * @param string Method name * @param array Array containing all the arguments for the original call * @return KControllerBread * * @see http://martinfowler.com/bliki/FluentInterface.html */ public function __call($method, $args) { //Check first if we are calling a mixed in method. //This prevents the model being loaded durig object instantiation. if (!isset($this->_mixed_methods[$method]) && $method != 'display') { //Check if the method is a state property $view = $this->getView(); $view->{$method}($args[0]); return $this; } return parent::__call($method, $args); }
/** * Put action * * This function translates a PUT request into an edit or add action. Only if the model * state is unique and the item exists an edit action will be executed, if the resources * doesn't exist and the state is unique an add action will be executed. * * If the resource already exists it will be completely replaced based on the data * available in the request. * * @param KCommandContext A command context object * @return KDatabaseRow(set) A row(set) object containing the modified data * @throws KControllerException If the model state is not unique */ protected function _actionPut(KCommandContext $context) { $data = $this->getModel()->getItem(); if ($this->getModel()->getState()->isUnique()) { $action = 'add'; if (!$data->isNew()) { //Reset the row data $data->reset(); $action = 'edit'; } //Set the row data based on the unique state information $state = $this->getModel()->getState()->getData(true); $data->setData($state); $data = parent::execute($action, $context); } else { $context->setError(new KControllerException(ucfirst('Resource not found', KHttpResponse::BAD_REQUEST))); } return $data; }