當前位置: 首頁>>代碼示例>>PHP>>正文


PHP Entity::toArray方法代碼示例

本文整理匯總了PHP中Espo\ORM\Entity::toArray方法的典型用法代碼示例。如果您正苦於以下問題:PHP Entity::toArray方法的具體用法?PHP Entity::toArray怎麽用?PHP Entity::toArray使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Espo\ORM\Entity的用法示例。


在下文中一共展示了Entity::toArray方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: getDataFromEntity

 protected function getDataFromEntity(Entity $entity)
 {
     $data = $entity->toArray();
     $fieldDefs = $entity->getFields();
     $fieldList = array_keys($fieldDefs);
     foreach ($fieldList as $field) {
         $type = null;
         if (!empty($fieldDefs[$field]['type'])) {
             $type = $fieldDefs[$field]['type'];
         }
         if ($type == Entity::DATETIME) {
             if (!empty($data[$field])) {
                 $data[$field] = $this->dateTime->convertSystemDateTime($data[$field]);
             }
         } else {
             if ($type == Entity::DATE) {
                 if (!empty($data[$field])) {
                     $data[$field] = $this->dateTime->convertSystemDate($data[$field]);
                 }
             } else {
                 if ($type == Entity::JSON_ARRAY) {
                     if (!empty($data[$field])) {
                         $list = $data[$field];
                         $newList = [];
                         foreach ($list as $item) {
                             $v = $item;
                             if ($item instanceof \StdClass) {
                                 $v = get_object_vars($v);
                             }
                             foreach ($v as $k => $w) {
                                 $v[$k] = $this->format($v[$k]);
                             }
                             $newList[] = $v;
                         }
                         $data[$field] = $newList;
                     }
                 } else {
                     if ($type == Entity::JSON_OBJECT) {
                         if (!empty($data[$field])) {
                             $value = $data[$field];
                             if ($value instanceof \StdClass) {
                                 $data[$field] = get_object_vars($value);
                             }
                             foreach ($data[$field] as $k => $w) {
                                 $data[$field][$k] = $this->format($data[$field][$k]);
                             }
                         }
                     }
                 }
             }
         }
         if (array_key_exists($field, $data)) {
             $data[$field] = $this->format($data[$field]);
         }
     }
     return $data;
 }
開發者ID:naushrambo,項目名稱:espocrm,代碼行數:57,代碼來源:Htmlizer.php

示例2: save

 public function save(Entity $entity)
 {
     if ($entity->id) {
         $this->data[$entity->id] = $entity->toArray();
         $fileName = $this->getFilePath($entity->id);
         $this->getFileManager()->putContents($fileName, json_encode($this->data[$entity->id]));
         return $entity;
     }
 }
開發者ID:jdavis593,項目名稱:appitechture,代碼行數:9,代碼來源:Preferences.php

示例3: save

 public function save(Entity $entity)
 {
     if ($entity->id) {
         $this->data[$entity->id] = $entity->toArray();
         $fields = $fields = $this->getMetadata()->get('entityDefs.Preferences.fields');
         $data = array();
         foreach ($this->data[$entity->id] as $field => $value) {
             if (empty($fields[$field]['notStorable'])) {
                 $data[$field] = $value;
             }
         }
         $fileName = $this->getFilePath($entity->id);
         $this->getFileManager()->putContents($fileName, Json::encode($data, \JSON_PRETTY_PRINT));
         $this->storeAutoFollowEntityTypeList($entity);
         return $entity;
     }
 }
開發者ID:naushrambo,項目名稱:espocrm,代碼行數:17,代碼來源:Preferences.php


注:本文中的Espo\ORM\Entity::toArray方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。