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


PHP DataGenerator::defaultValueForObject方法代码示例

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


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

示例1: setDefaultValues

 /**
  * This method checks if there is any data prepared for record or it uses
  * default data based on type of the field.
  *
  * It looks for data for each field in record in following order:
  * 1. Checks if data is set in DataObject
  * 2. Checks data from data container (@see setData())
  * 3. Checks data from $defaultValues variables defined in each DataObject
  * 4. Generate data based on type of the field
  *
  * It populates primary keys fields only if data for key field was specifically
  * set using any of methods defined in 1, 2 or 3 (it doesn't
  * populate it with default data based on field type)
  *
  * @param DataObject $do    DataObject to populate data in
  * @param int $counter      Used to generate a key for data container array to retreive data
  * @access package private
  * @static
  */
 function setDefaultValues(&$do, $counter = 0)
 {
     $fields = $do->table();
     $keys = $do->keys();
     $table = $do->getTableWithoutPrefix();
     foreach ($fields as $fieldName => $fieldType) {
         if (!isset($do->{$fieldName})) {
             if (!empty($this) && is_a($this, 'DataGenerator')) {
                 $fieldValue = $this->getFieldValueFromDataContainer($table, $fieldName, $counter);
             } else {
                 $fieldValue = DataGenerator::getFieldValueFromDataContainer($table, $fieldName, $counter);
             }
             if (!isset($fieldValue) && !in_array($fieldName, $keys)) {
                 $fieldValue = DataGenerator::defaultValueForObject($do, $fieldName, $fieldType);
                 if (!isset($fieldValue)) {
                     $fieldValue = DataGenerator::defaultValueByType($fieldType);
                 }
             }
             if (isset($fieldValue)) {
                 if ($fieldValue != OA_DATAOBJECT_DEFAULT_NULL) {
                     // exception for NULLs
                     $do->{$fieldName} = $fieldValue;
                 }
             }
         }
     }
 }
开发者ID:villos,项目名称:tree_admin,代码行数:46,代码来源:DataGenerator.php


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