__set() public method

Magic setter method, allows $model->property = 'value' access to data.
public __set ( string $property, string $value ) : void
$property string
$value string
return void
Example #1
0
 /**
  * {@inheritdoc}
  */
 public function __set($strKey, $varValue)
 {
     if ($this->arrRelations[$strKey]['type'] == 'haste-ManyToMany' && !is_array($varValue)) {
         throw new \InvalidArgumentException('Values set on many-to-many relation fields have to be an array');
     }
     parent::__set($strKey, $varValue);
 }
Example #2
0
 /**
  * Dynamic setter that serializes results.
  */
 public function __set($key, $val)
 {
     if ($key == 'results') {
         $this->_results = $val;
         $this->data[$key] = json_encode($val);
         return;
     }
     return parent::__set($key, $val);
 }
Example #3
0
 /**
  * Magic method for setting protected object properties from outside.
  *
  * @param string $name  Property name
  * @param mixed  $value Value to be assigned
  */
 public function __set($name, $value)
 {
     parent::__set($name, $value);
     $length = 100;
     $omission = '…';
     if ('notation' == $name) {
         $this->notationhash = substr(md5(mb_convert_case(trim($this->notation), MB_CASE_LOWER)), 0, 10);
         return;
     }
     if ('contextstart' == $name) {
         if (mb_strlen($this->contextstart) >= $length and false !== ($pos = strrpos($this->contextstart, ' ', -$length))) {
             // Limit length of the context start
             $this->contextstart = $omission . substr($this->contextstart, $pos);
         }
         return;
     }
     if ('contextend' == $name) {
         if (mb_strlen($this->contextend) >= $length and false !== ($pos = strpos($this->contextend, ' ', $length))) {
             // Limit length of the context end
             $this->contextend = substr($this->contextend, 0, $pos) . $omission;
         }
     }
 }
Example #4
0
File: Form.php Project: Alm001/form
 /**
  * Dynamic setter that serializes fields and actions.
  */
 public function __set($key, $val)
 {
     if ($key == 'field_list') {
         $this->_fields = $val;
         $this->data['fields'] = json_encode($val);
         return;
     } elseif ($key == 'actions') {
         $this->_actions = $val;
         $this->data[$key] = json_encode($val);
         return;
     }
     return parent::__set($key, $val);
 }
Example #5
0
 /**
  * Dynamic setter for extended properties field. If you set the field
  * specified in the child class's `$_extended_field` property, it will
  * automatically serialize it into JSON for storage.
  *
  * If an extended property has been defined in the `$verify` list, you can
  * also set it directly using the usual `$model->property = '...'` syntax.
  */
 public function __set($key, $val)
 {
     if ($key === $this->_extended_field) {
         $this->_extended = $val;
         $this->data[$key] = json_encode($val);
         return;
     } elseif (isset($this->_extended_verify[$key])) {
         return $this->ext($key, $val);
     }
     return parent::__set($key, $val);
 }
Example #6
0
 public function __set($property, $value)
 {
     $this->checkSetColumnPermissions($property);
     parent::__set($property, $value);
 }
Example #7
0
 public function __set($name, $value)
 {
     parent::__set($name, $name == 'password' ? md5($value) : $value);
 }
Example #8
0
 function i18n($lang = null)
 {
     // If i18n is not enabled, return itself
     if (!Kennel::getSetting('i18n', 'enabled')) {
         return $this;
     }
     if (!$lang) {
         $lang = i18n::getLang();
     }
     $primaryKey = $this->schema->getPrimaryKey()->name;
     $this->_fetchI18n();
     foreach ($this->_i18n as $i18n) {
         if ($i18n->lang == $lang) {
             return $i18n;
         }
     }
     // If no localized version was found, create one now
     $primaryKey = $this->schema->getPrimaryKey()->name;
     $i18n = new Model("{$this->model_name}_i18n");
     $i18n->__set("{$this->model_name}_{$primaryKey}", $this->{$primaryKey});
     $i18n->lang = $lang;
     // … and populate it with default values, if any.
     // Useful as base data for internationalization of existing, populated models
     foreach ($i18n->_data as $key => $value) {
         if ($key != 'id' && isset($this->_data[$key])) {
             $i18n->{$key} = $this->{$key};
         }
     }
     return $this->_i18n[] = $i18n;
 }