当前位置: 首页>>代码示例>>PHP>>正文


PHP ObjectMixin::set方法代码示例

本文整理汇总了PHP中Nette\ObjectMixin::set方法的典型用法代码示例。如果您正苦于以下问题:PHP ObjectMixin::set方法的具体用法?PHP ObjectMixin::set怎么用?PHP ObjectMixin::set使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Nette\ObjectMixin的用法示例。


在下文中一共展示了ObjectMixin::set方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: __set

 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);
     }
 }
开发者ID:fabik,项目名称:database,代码行数:9,代码来源:ActiveRow.php

示例2: __set

 /**
  * 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);
 }
开发者ID:genextwebs,项目名称:dropbox-sample,代码行数:11,代码来源:CachingIterator.php

示例3: __set

 public function __set($name, $value)
 {
     return ObjectMixin::set($this, $name, $value);
 }
开发者ID:kravco,项目名称:nette,代码行数:4,代码来源:ClassType.php

示例4: __set

 function __set($name, $value)
 {
     return Nette\ObjectMixin::set($this, $name, $value);
 }
开发者ID:rotten77,项目名称:xcv,代码行数:4,代码来源:nette.min.php

示例5: __set

 /**
  * 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;
     }
 }
开发者ID:matak,项目名称:dbrecord,代码行数:81,代码来源:Entity.php

示例6: __set

 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);
 }
开发者ID:jsmitka,项目名称:ExtensionObjects,代码行数:18,代码来源:ExtensibleObject.php


注:本文中的Nette\ObjectMixin::set方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。