/** * 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; } }
/** * Get the number of affected rows * * @param integer $affected * @return DatabaseContext */ public function setAffected($affected) { return ObjectConfig::set('affected', $affected); }
/** * Set the identity key * * @param mixed $value * @return ModelContext */ public function setIdentityKey($value) { return ObjectConfig::set('identity_key', $value); }
/** * Set a command property or attribute * * If an command property exists the property will be set, otherwise an attribute will be added. * * @param string $name * @param mixed $value * @return Command */ 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 a configuration item * * @param string $name * @param mixed $value * @return void */ public function set($name, $value) { if (is_array($value)) { $value = new ObjectConfig($value); } parent::set($name, $value); }
/** * Set the view parameters * * @param array $parameters * @return ViewContext */ public function setParameters($parameters) { return ObjectConfig::set('parameters', $parameters); }
/** * Set the model entity * * @param ModelEntityInterface $entity * @return ControllerContextModel */ public function setEntity($entity) { return ObjectConfig::set('entity', $entity); }
/** * Set the view layout * * @param string $layout * @return ViewContextTemplate */ public function setLayout($layout) { return ObjectConfig::set('layout', $layout); }
/** * Set the model query * * @param DatabaseQueryInterface $query * @return ModelContext */ public function setQuery($query) { return ObjectConfig::set('query', $query); }
/** * Set the user object * * @param UserInterface $user * @return $this */ public function setUser(UserInterface $user) { return ObjectConfig::set('user', $user); }