/** * Set a configuration element * * @param string * @param mixed * @return void */ public function set($name, $value) { parent::set($name, $value); //Only calculate the limit and offset if we have a total if ($this->total) { $this->limit = (int) max($this->limit, 1); $this->offset = (int) max($this->offset, 0); if ($this->limit > $this->total) { $this->offset = 0; } if (!$this->limit) { $this->offset = 0; $this->limit = $this->total; } $this->count = (int) ceil($this->total / $this->limit); if ($this->offset > $this->total) { $this->offset = ($this->count - 1) * $this->limit; } $this->current = (int) floor($this->offset / $this->limit) + 1; } }
/** * Set the identity key * * @param mixed $value * @return KModelContext */ public function setIdentityKey($value) { return KObjectConfig::set('identity_key', $value); }
/** * Set the view data * * @param array $data * @return KViewContext */ public function setData($data) { return KObjectConfig::set('data', $data); }
/** * Set the controller action * * @param string $action * @return KControllerContext */ public function setAction($action) { return KObjectConfig::set('action', $action); }
/** * Sets the time limit * * @param KObjectConfig|array $state * @return $this */ public function setState($state) { return KObjectConfig::set('state', $state); }
/** * Set the view layout * * @param string $layout * @return KViewContextTemplate */ public function setLayout($layout) { return KObjectConfig::set('layout', $layout); }
/** * Set a command property or attribute * * If an event property exists the property will be set, otherwise an attribute will be added. * * @param string $name * @param mixed $value * @return KCommand */ public final function set($name, $value) { $method = 'set' . ucfirst($name); if (!method_exists($this, $method)) { parent::set($name, $value); } else { $this->{$method}($value); } return $this; }
/** * Set the exception * * @param Exception $exception */ public function setException(Exception $exception) { return KObjectConfig::set('exception', $exception); }
/** * Get the number of affected rows * * @param integer $affected * @return KDatabaseContext */ public function setAffected($affected) { return KObjectConfig::set('affected', $affected); }
/** * Set a configuration item * * @param string $name * @param mixed $value * @return void */ public function set($name, $value) { if (is_array($value)) { $value = new KObjectConfig($value); } parent::set($name, $value); }