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


PHP DataObjectInterface::setCastedField方法代码示例

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


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

示例1: saveInto

 public function saveInto(DataObjectInterface $record)
 {
     if ($this->name) {
         $value = $this->dataValue();
         $file = null;
         if ($value['id']) {
             $file = CloudinaryFile::get()->byID($value['id']);
         }
         if (!$file) {
             $file = new CloudinaryFile();
         }
         if ($value['resource_type'] == 'image') {
             $file->ClassName = 'CloudinaryImage';
         }
         if ($value['url']) {
             $file->update(array('CloudinaryURL' => $value['url'], 'Title' => $value['title'], 'Size' => $value['size'], 'FileName' => $value['filename'], 'ResourceType' => $value['resource_type'], 'Height' => (int) $value['height'], 'Width' => (int) $value['width'], 'Format' => $value['format']));
             $file->write();
             $record->setCastedField($this->name . 'ID', $file->ID);
         } else {
             if ($file->exists()) {
                 $file->delete();
             }
             $record->setCastedField($this->name . 'ID', 0);
         }
     }
 }
开发者ID:silverstripers,项目名称:cloudinary,代码行数:26,代码来源:CloudinaryUpload.php

示例2: saveInto

 public function saveInto(\DataObjectInterface $record)
 {
     if ($this->name) {
         $castingHelper = $record->castingHelper($this->name);
         if ($castingHelper == 'Boolean') {
             $record->setCastedField($this->name, $this->getBooleanValue());
         } else {
             $record->setCastedField($this->name, $this->dataValue());
         }
     }
 }
开发者ID:lekoala,项目名称:silverstripe-form-extras,代码行数:11,代码来源:YesNoOptionsetField.php

示例3: saveInto

 public function saveInto(\DataObjectInterface $record)
 {
     if (!$this->dataValue()) {
         return;
     }
     $record->setCastedField('AdministrativeArea', BelgianGeoUtils::getProvinceRegion($this->dataValue()));
     return parent::saveInto($record);
 }
开发者ID:helpfulrobot,项目名称:lekoala-silverstripe-geotools,代码行数:8,代码来源:BelgianProvinceField.php

示例4: saveInto

 public function saveInto(DataObjectInterface $record)
 {
     if ($this->record) {
         // HACK: Use a fake Form object to save data into fields
         $form = new Form($this->record, $this->name . '-form', $this->FieldList(false), new FieldList());
         $form->loadDataFrom($this->value);
         $form->saveInto($this->record);
         // Save extra data into field
         if (count($this->extraData)) {
             $this->record->castedUpdate($this->extraData);
         }
         if (!$this->record->ID && count($this->defaultFromParent)) {
             foreach ($this->defaultFromParent as $pField => $rField) {
                 if (is_numeric($pField)) {
                     if ($this->record->{$rField}) {
                         continue;
                     }
                     $this->record->setCastedField($rField, $record->{$rField});
                 } else {
                     if ($this->record->{$pField}) {
                         continue;
                     }
                     $this->record->setCastedField($rField, $record->{$pField});
                 }
             }
         }
         if (count($this->overrideFromParent)) {
             foreach ($this->overrideFromParent as $pField => $rField) {
                 if (is_numeric($pField)) {
                     $this->record->setCastedField($rField, $record->{$rField});
                 } else {
                     $this->record->setCastedField($rField, $record->{$pField});
                 }
             }
         }
         $this->record->write();
         $fieldName = substr($this->name, -2) == 'ID' ? $this->name : $this->name . 'ID';
         $record->{$fieldName} = $this->record->ID;
         unset($form);
     }
 }
开发者ID:helpfulrobot,项目名称:milkyway-silverstripe-hasonecompositefield,代码行数:41,代码来源:HasOneCompositeField.php

示例5: saveInto

 /**
  * Method to save this form field into the given data object.
  * By default, makes use of $this->dataValue()
  * 
  * @param DataObjectInterface $record DataObject to save data into
  */
 public function saveInto(DataObjectInterface $record)
 {
     if ($this->name) {
         $record->setCastedField($this->name, $this->dataValue());
     }
 }
开发者ID:8secs,项目名称:cocina,代码行数:12,代码来源:FormField.php

示例6: saveInto

 /**
  * Take the latitude/longitude fields and save them to the DataObject.
  * {@inheritdoc}
  */
 public function saveInto(DataObjectInterface $record)
 {
     $record->setCastedField($this->childFieldName('Latitude'), $this->latField->dataValue());
     $record->setCastedField($this->childFieldName('Longitude'), $this->lngField->dataValue());
     $record->setCastedField($this->childFieldName('Zoom'), $this->zoomField->dataValue());
     return $this;
 }
开发者ID:helpfulrobot,项目名称:betterbrief-silverstripe-googlemapfield,代码行数:11,代码来源:GoogleMapField.php

示例7: saveInto

 /**
  * Save
  *
  * @param DataObjectInterface $record
  */
 public function saveInto(DataObjectInterface $record)
 {
     $value = $this->value;
     /**
      * If the $this->value has multiple values.
      */
     if (is_array($value)) {
         $combinedArray = array('selector' => $this->selector);
         if (is_array($this->fields)) {
             foreach ($this->fields as $key => $item) {
                 $combinedArray = array_merge($combinedArray, array($key => $value[$key]));
             }
         }
         $return = json_encode($combinedArray);
     } else {
         $return = $value;
     }
     /**
      * If name exists:
      * Save content from a form into a field on this data object.
      */
     if ($this->name) {
         $record->setCastedField($this->name, $return);
     }
 }
开发者ID:helpfulrobot,项目名称:toastnz-silverstripe-design-field,代码行数:30,代码来源:DesignField.php

示例8: saveInto

 function saveInto(DataObjectInterface $record)
 {
     $relation = $this->getRelation();
     if ($relation) {
         $submittedTags = explode($this->getDelimiter(), $this->value);
         $tagClass = $this->getTagClass();
         $tagLabelField = $this->getTagLabelField();
         $tagObjects = DataList::create($tagClass)->filter($tagLabelField, $submittedTags);
         if ($tagObjects->Count() < count($submittedTags)) {
             // filter out the tags that exist already
             $tagsAsKeys = array_flip($submittedTags);
             foreach ($tagObjects as $tag) {
                 $label = $tag->{$tagLabelField};
                 unset($tagsAsKeys[$label]);
             }
             foreach ($tagsAsKeys as $label => $value) {
                 $tagObject = new $tagClass();
                 $tagObject->{$tagLabelField} = $label;
                 $tagObject->write();
                 $tagObjects->add($tagObject);
             }
         }
         $relationList = $this->form->record->{$this->name}();
         $oldTags = $relationList->map('ID', $tagLabelField)->toArray();
         $relationList->removeAll();
         $relationList->addMany($tagObjects->toArray());
         if ($this->deleteUnusedTags) {
             $deletedTags = array_diff($oldTags, $tagObjects->map('ID', $tagLabelField)->toArray());
             if (count($deletedTags) > 0) {
                 $relationTable = $relation[4];
                 foreach ($deletedTags as $id => $title) {
                     $query = new SQLQuery();
                     $query->select = array('ID', $tagLabelField);
                     $query->from = array($relationTable);
                     $query->where = array("ID = " . $id);
                     $count = $query->Count();
                     if ($count == 0) {
                         DataObject::delete_by_id($tagClass, $id);
                     }
                 }
             }
         }
     } else {
         if ($record->hasField($this->name)) {
             $record->setCastedField($this->name, $this->dataValue());
         } else {
             // @TODO: better error handling
         }
     }
 }
开发者ID:nathancox,项目名称:silverstripe-tagitfield,代码行数:50,代码来源:TagItField.php

示例9: saveInto

 /**
  * Allow spam flag to be saved to the underlying data record
  *
  * @param \DataObjectInterface $record
  */
 public function saveInto(\DataObjectInterface $record)
 {
     if (Config::inst()->get('AkismetSpamProtector', 'save_spam')) {
         $dataValue = $this->getIsSpam() ? 1 : 0;
         $record->setCastedField($this->name, $dataValue);
     }
 }
开发者ID:helpfulrobot,项目名称:tractorcow-silverstripe-akismet,代码行数:12,代码来源:AkismetField.php

示例10: 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


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