public function __set($key, $value) { $column = $this->formatColumnName($key); if (parent::__isset($column) || !ObjectMixin::has($this, $key)) { parent::__set($column, $value); } else { ObjectMixin::set($this, $key, $value); } }
/** * Sets value of a property. Do not call directly. * @param string property name * @param mixed property value * @return void * @throws Nette\MemberAccessException if the property is not defined or is read-only */ public function __set($name, $value) { Nette\ObjectMixin::set($this, $name, $value); }
public function __set($name, $value) { return ObjectMixin::set($this, $name, $value); }
function __set($name, $value) { return Nette\ObjectMixin::set($this, $name, $value); }
/** * Sets value of a property. Do not call directly. * * @param string property name * @param mixed property value * @return void * @throws MemberAccessException if the property is not defined or is read-only */ public function __set($name, $value) { $this->updating(); try { ObjectMixin::set($this, $name, $value); } catch (\Nette\MemberAccessException $e) { $repository = self::em()->getRepository(static::class); $metadata = $repository->getMetadata(); // je to Column if ($metadata->hasColumn($name)) { // hodnoty ktere mohou byt NULL a nemaji v dtb zadnou vychozi hodnotu nebudeme ukladat jako prazdne ale jako NULL // jinak by se do dtb zapsal prazdny string coz napr. u company, ico atd. nema vyznam, dokonce to i u ICO vyrazne skodi //TODO: docela potencionalni bug / asi by se to melo resit jinde - napr. parametrem v konstruktoru if (isset($this->_construction['nullableToNULL']) && $this->_construction['nullableToNULL'] === true) { if ($value === "" && $metadata->isNullable($name) && !$metadata->isMandatory($name)) { $value = NULL; } } if (!is_null($value)) { $type = $metadata->getType($name); switch ($type) { case "s": $value = (string) $value; // trimstrings oreze vsechny stringy funkci trim if (isset($this->_construction['trimStrings']) && $this->_construction['trimStrings'] === true) { $value = trim($value); } break; case "i": $value = (int) $value; break; case "f": if (isset($this->_construction['floatReplaceDecimals']) && $this->_construction['floatReplaceDecimals'] === true) { $value = preg_replace("/,/", ".", $value); } $value = (double) $value; break; case "d": case "t": // z dtb vzdy dostaneme tento tvar 2010-01-01 / z formu muzeme dostat ledasco / my budeme pracovat s DateTime / pri ukladani do dtb nebo do array bychom meli ulozit string, tedy Y-m-d H:i:s // povazujeme za NULL if (!$value || $value == '0000-00-00 00:00:00') { $value = NULL; } else { $_value = is_numeric($value) ? (int) $value : strtotime($value); // strtotime si poradí se stringy jako 2010-01-10 12:00, 10.1.2010 12:00, now atd., tedy při vkládání formulářů máme celkem volné ruce $value = new DateTime(); $value->setTimestamp($_value); } break; default: throw new \Nette\InvalidArgumentException("Undefined data type!"); } } if (!array_key_exists($name, $this->_data) || $this->_data[$name] !== $value) { $this->_data[$name] = $value; $this->_modified[$name] = true; } } elseif ($metadata->hasAssociation($name)) { // mame mergovat? if (is_array($value) && isset($this->_construction['mergeAssociations']) && $this->_construction['mergeAssociations'] === true && isset($this->_associations[$name])) { $association = $this->_associations[$name]; $association->setValues($value, $this->_construction); return; } $reference = $repository->saveAssociatedObject($name, $this, $value, $this->_construction); $this->_associations[$name] = $reference; return; } // jde o chybu throw $e; } }
public function __set($name, $value) { foreach ($this->getExtensions() as $extension) { /* @var $extension ExtensionObject */ if ($extension->getReflection()->hasProperty($name)) { $property = $extension->getReflection()->getProperty($name); if ($property->isPublic() && !$property->isStatic()) { $extension->{$name} = $value; return; } } if (ObjectMixin::has($extension, $name)) { ObjectMixin::set($extension, $name, $value); return; } } return parent::__set($name, $value); }