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


PHP UploadField::saveInto方法代码示例

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


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

示例1: saveInto

 public function saveInto(DataObjectInterface $record)
 {
     $isNew = !$record->exists();
     parent::saveInto($record);
     // if we're dealing with an unsaved record, we have to rebuild the relation list
     // with the proper meny_many_extraFields attributes (eg. the sort order)
     if ($isNew) {
         // we have to grab the raw post data as the data is in the right order there.
         // this is kind of a hack, but we simply lack the information about the client-side sorting otherwise
         if (isset($_POST[$this->name]) && isset($_POST[$this->name]['Files']) && is_array($_POST[$this->name]['Files'])) {
             $idList = $_POST[$this->name]['Files'];
         } else {
             // take the ItemIDs as a fallback
             $idList = $this->getItemIDs();
         }
         $sortColumn = $this->getSortColumn();
         $relationName = $this->getName();
         if ($relationName && $record->many_many($relationName) !== null && ($list = $record->{$relationName}())) {
             $arrayList = $list->toArray();
             foreach ($arrayList as $item) {
                 $list->remove($item);
                 $list->add($item, array($sortColumn => array_search($item->ID, $idList) + 1));
             }
         }
     }
 }
开发者ID:vinstah,项目名称:body,代码行数:26,代码来源:SortableUploadField.php

示例2: saveInto

 public function saveInto(DataObjectInterface $record)
 {
     $isNew = !$record->exists();
     parent::saveInto($record);
     // if we're dealing with an unsaved record, we have to rebuild the relation list
     // with the proper many_many_extraFields attributes (eg. the sort order)
     if ($isNew) {
         // we have to grab the raw post data as the data is in the right order there.
         // this is kind of a hack, but we simply lack the information about the client-side sorting otherwise
         if (isset($_POST[$this->name]) && isset($_POST[$this->name]['Files']) && is_array($_POST[$this->name]['Files'])) {
             $idList = $_POST[$this->name]['Files'];
         } else {
             // take the ItemIDs as a fallback
             $idList = $this->getItemIDs();
         }
         // Get general info about this relation (if possible)
         $sortColumn = $this->getSortColumn();
         $relationName = $this->getName();
         if ($relationName) {
             // Get relation type.
             $isManyMany = $record->many_many($relationName) !== null;
             // Using "null" here since we know it will properly return null if there is no many_many component by this name.
             $isHasMany = (bool) $record->has_many($relationName);
             // TODO: Return to more strict check of === null here when SS framework issue is mainstream: https://github.com/silverstripe/silverstripe-framework/pull/4130
             if ($isManyMany || $isHasMany) {
                 // Get list from that relation and begin to manipulate it.
                 $list = $record->{$relationName}();
                 $arrayList = $list->toArray();
                 foreach ($arrayList as $item) {
                     // Get the specified sort order for this item (offset from posted 0 index).
                     $sortOrder = array_search($item->ID, $idList) + 1;
                     // The method by which we update this relation varies depending on the relationship type...
                     if ($isManyMany) {
                         // Alter data in the pivot table.
                         $list->remove($item);
                         $list->add($item, array($sortColumn => $sortOrder));
                     } elseif ($isHasMany) {
                         // Just update information in the sort field directly on the item itself.
                         $item->{$sortColumn} = $sortOrder;
                         $item->write();
                     }
                 }
             }
         }
     }
 }
开发者ID:miamollie,项目名称:echoAerial,代码行数:46,代码来源:SortableUploadField.php

示例3: saveInto

 /**
  * Called before the dataobject record is saved.
  * @param DataObjectInterface $record The record.
  * @return [type]                      [description]
  */
 public function saveInto(DataObjectInterface $record)
 {
     // On the dataobject record set the lat, long, zoom fields (names specified by the dev at
     // time of construction) to the values of the lat long and zoom child fields of this class.
     $record->setCastedField($this->latFieldName, $this->latField->dataValue());
     $record->setCastedField($this->lngFieldName, $this->lngField->dataValue());
     $record->setCastedField($this->zoomFieldName, $this->zoomField->dataValue());
     // Do parent stuff as normal.
     return parent::saveInto($record);
 }
开发者ID:zarocknz,项目名称:silverstripe-geodata-uploadfield,代码行数:15,代码来源:GeodataUploadField.php


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