Example #1
0
 /**
  * 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;
     }
 }
Example #2
0
 /**
  * Get the number of affected rows
  *
  * @param integer $affected
  * @return DatabaseContext
  */
 public function setAffected($affected)
 {
     return ObjectConfig::set('affected', $affected);
 }
Example #3
0
 /**
  * Set the identity key
  *
  * @param mixed $value
  * @return ModelContext
  */
 public function setIdentityKey($value)
 {
     return ObjectConfig::set('identity_key', $value);
 }
Example #4
0
 /**
  * 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;
 }
Example #5
0
 /**
  * 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);
 }
Example #6
0
 /**
  * Set the view parameters
  *
  * @param array $parameters
  * @return ViewContext
  */
 public function setParameters($parameters)
 {
     return ObjectConfig::set('parameters', $parameters);
 }
Example #7
0
 /**
  * Set the model entity
  *
  * @param ModelEntityInterface $entity
  * @return ControllerContextModel
  */
 public function setEntity($entity)
 {
     return ObjectConfig::set('entity', $entity);
 }
Example #8
0
 /**
  * Set the view layout
  *
  * @param string $layout
  * @return ViewContextTemplate
  */
 public function setLayout($layout)
 {
     return ObjectConfig::set('layout', $layout);
 }
Example #9
0
 /**
  * Set the model query
  *
  * @param DatabaseQueryInterface $query
  * @return ModelContext
  */
 public function setQuery($query)
 {
     return ObjectConfig::set('query', $query);
 }
Example #10
0
 /**
  * Set the user object
  *
  * @param UserInterface $user
  * @return $this
  */
 public function setUser(UserInterface $user)
 {
     return ObjectConfig::set('user', $user);
 }