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


PHP Entity::toArray方法代码示例

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


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

示例1: adaptCustomFields

 /**
  * Watches config for this entity's custom fields, if any key value pair matches 
  * a custom field name, it is extracted from the values and added to a new value with key
  * 'custom_fields'
  * 
  * @param \EntityPopulator\Entities\Entity $entity The Redmine entity being created 
  * treated.
  * 
  * @return void
  */
 public static function adaptCustomFields(Entity $entity)
 {
     $customFields = $entity->getCustomFieldsConfig();
     $fields = $entity->toArray();
     $usedCustomFields = array_intersect_key($fields, $customFields);
     if (0 < count($usedCustomFields)) {
         $apiReadyCustomFields = self::createCustomFields($entity, $usedCustomFields);
         $nativeFields = array_diff_key($fields, $customFields);
         $nativeFields += $apiReadyCustomFields;
         $entity->fromArray($nativeFields);
     }
 }
开发者ID:kismet,项目名称:RedmineIssueImporter,代码行数:22,代码来源:Entity.php

示例2: makeSetterGetterDoc

 /**
  * Generate the setter and getter method PHPDoc declaration to paste into your entity class.
  *
  * @param Entity $entity
  */
 public static function makeSetterGetterDoc(Entity $entity)
 {
     $properties = $entity->toArray(false);
     $entityName = $entity->calledClassName();
     echo "<pre>\n";
     foreach ($properties as $name => $value) {
         $methodName = ucfirst($name);
         $type = $entity->typeof($name);
         echo " * @method {$entityName} set{$methodName}({$type} \$value)\n";
         echo " * @method {$type} get{$methodName}()\n";
     }
     echo "</pre>\n";
 }
开发者ID:codeblanche,项目名称:entity,代码行数:18,代码来源:Utils.php

示例3: update

 /**
  * @param Entity $entity
  * @return int Returns the number of rows affected by the query 
  */
 public function update(Entity $entity)
 {
     $vars = $entity->toArray();
     unset($vars['id'], $vars['created_at']);
     if (array_key_exists('updated_at', $vars)) {
         $vars['updated_at'] = date('Y-m-d H:i:s');
         $entity->addUpdated('updated_at');
     }
     $updatedColumns = $entity->getUpdated();
     if (count($updatedColumns) <= 0) {
         return false;
     }
     $entity->resetUpdated();
     $columns = '';
     $values = array();
     foreach ($updatedColumns as $column) {
         $columns .= '`' . $column . '` = ?,';
         $values[] = $vars[$column];
     }
     $sql = 'UPDATE ' . $this->table . ' SET ' . rtrim($columns, ',') . ' WHERE id = ' . $entity->id;
     $stmt = $this->execute($sql, $values);
     return $stmt instanceof PDOStatement ? $stmt->rowCount() : false;
 }
开发者ID:sayi21cn,项目名称:apify-library,代码行数:27,代码来源:Model.php

示例4: toArray

 public function toArray()
 {
     $result = parent::toArray();
     $result['content'] = Utility::DecodeAsSafeString($result['content']);
     return $result;
 }
开发者ID:leloulight,项目名称:didapi,代码行数:6,代码来源:post.php

示例5: decodeAnswer

 /**
  * Returns [$sector, $rank] (both strings) of the sector that an
  * answer is about and the rank the respondent gave to it.
  *
  * @param array $answer Answer array
  * @param Entity $survey The result of a call to SurveysTable::get()
  * @return array [$sector, $rank]
  */
 public function decodeAnswer($answer, $survey)
 {
     $answerIds = $survey->toArray();
     $sectorId = $answer['row'];
     $sector = str_replace('_aid', '', array_search($sectorId, $answerIds));
     $rankId = $answer['col'];
     $rank = str_replace('_aid', '', array_search($rankId, $answerIds));
     return [$sector, $rank];
 }
开发者ID:BallStateCBER,项目名称:cri,代码行数:17,代码来源:ResponsesTable.php

示例6: update

 /**
  * Update an existing user.
  *
  * @param  \Stidges\LaravelDbNormalizer\Entity  $user
  * @return bool
  */
 public function update(Entity $user)
 {
     $model = $this->model->newInstance($user->toArray(), true);
     $model->id = $user->id;
     return $user->getDirtyAttributes() ? $model->save() : $model->touch();
 }
开发者ID:dhaval48,项目名称:laravel-db-normalizer,代码行数:12,代码来源:EloquentUserRepository.php

示例7: update

 /**
  * Update an existing user.
  *
  * @param  \Stidges\LaravelDbNormalizer\Entity  $user
  * @return bool
  */
 public function update(Entity $user)
 {
     $data = array_only($user->toArray(), $this->fillable);
     return (bool) $this->db->table($this->table)->where('id', $user->id)->update($data);
 }
开发者ID:dhaval48,项目名称:laravel-db-normalizer,代码行数:11,代码来源:DbUserRepository.php

示例8: toArray

 public function toArray()
 {
     $attribute_values = parent::toArray();
     $attribute_values[self::OBJECT_TYPE] = $this->getType()->getVariantPrefix();
     return $attribute_values;
 }
开发者ID:honeybee,项目名称:honeybee,代码行数:6,代码来源:Projection.php


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