• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

PHP DataObjectInterface类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



在下文中一共展示了DataObjectInterface类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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)
 {
     $schemas = $record->getSchemas();
     $value = $this->Value();
     $metadata = array();
     foreach ($schemas as $schema) {
         $metadata[$schema->Name] = array();
         $fields = $schema->getFormFields();
         $namesMap = array();
         foreach ($fields as $field) {
             $brPos = strrpos($field->getName(), '[');
             $name = substr($field->getName(), $brPos + 1, -1);
             $namesMap[$field->getName()] = $name;
         }
         if (isset($value[$schema->Name])) {
             foreach ($fields as $field) {
                 $fName = $field->getName();
                 $sName = $namesMap[$fName];
                 if (array_key_exists($sName, $value[$schema->Name])) {
                     $field->setValue($value[$schema->Name][$sName], $value[$schema->Name]);
                 } else {
                     $field->setValue(null);
                 }
             }
         }
         foreach ($fields as $field) {
             $name = $namesMap[$field->getName()];
             $schemaField = $schema->Fields()->find('Name', $name);
             $toSave = $schemaField->processBeforeWrite($field->dataValue(), $record);
             $metadata[$schema->Name][$name] = $toSave;
         }
     }
     $record->{$this->name} = serialize($metadata);
 }
开发者ID:helpfulrobot,项目名称:silverstripe-australia-metadata,代码行数:34,代码来源:MetadataSetField.php


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


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


示例5: saveInto

 public function saveInto(DataObjectInterface $record)
 {
     $value = $this->value;
     $fieldName = $this->getName();
     if ($record->has_one($fieldName)) {
         $record->{$fieldName . 'ID'} = $value;
     }
     return $this;
 }
开发者ID:nathancox,项目名称:silverstripe-modifieduploadfield,代码行数:9,代码来源:ModifiedUploadField.php


示例6: saveInto

 /**
  * SaveInto checks if set-methods are available and use them instead of setting the values directly. saveInto
  * initiates a new LinkField class object to pass through the values to the setter method.
  */
 function saveInto(DataObjectInterface $dataObject)
 {
     $fieldName = $this->name;
     if ($dataObject->hasMethod("set{$fieldName}")) {
         $dataObject->{$fieldName} = DBField::create('AlternativeField', array("SelectedValue" => $this->fieldSelectedValue->Value(), "AlternativeValue" => $this->fieldAlternativeValue->Value()));
     } else {
         $dataObject->{$fieldName}->setSelectedValue($this->fieldSelectedValue->Value());
         $dataObject->{$fieldName}->setAlternativeValue($this->fieldAlternativeValue->Value());
     }
 }
开发者ID:helpfulrobot,项目名称:leapfrognz-alternative-field,代码行数:14,代码来源:AlternativeFormField.php


示例7: saveInto

 /**
  * SaveInto checks if set-methods are available and use them instead of setting the values directly. saveInto
  * initiates a new LinkField class object to pass through the values to the setter method.
  */
 public function saveInto(DataObjectInterface $dataObject)
 {
     $fieldName = $this->name;
     if ($dataObject->hasMethod("set{$fieldName}")) {
         $dataObject->{$fieldName} = DBField::create('LinkField', array("PageID" => $this->fieldPageID->Value(), "CustomURL" => $this->fieldCustomURL->Value()));
     } else {
         $dataObject->{$fieldName}->setPageID($this->fieldPageID->Value());
         $dataObject->{$fieldName}->setCustomURL($this->fieldCustomURL->Value());
     }
 }
开发者ID:helpfulrobot,项目名称:lrc-silverstripe-link-field,代码行数:14,代码来源:LinkFormField.php


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


示例9: saveInto

 /**
  * Save value to dataobject
  *
  * @see forms/CheckboxSetField::saveInto()
  */
 public function saveInto(DataObjectInterface $record)
 {
     $fieldName = $this->getName();
     $valueArray = is_array($this->value) && isset($this->value[0]) && strpos($this->value[0], ',') ? explode(',', $this->value[0]) : $this->value;
     if ($fieldName && ($record->has_many($fieldName) || $record->many_many($fieldName))) {
         // Set related records
         $record->{$fieldName}()->setByIDList($valueArray);
     } else {
         $record->{$fieldName} = is_array($this->value) ? implode(',', $this->value) : $this->value;
         $record->write();
     }
 }
开发者ID:swilsonalfa,项目名称:silverstripe-multiselectfield,代码行数:17,代码来源:MultiSelectField.php


示例10: saveInto

 function saveInto(DataObjectInterface $record)
 {
     $fieldName = $this->name;
     $fieldNameID = $fieldName . 'ID';
     $record->{$fieldNameID} = 0;
     if ($val = $this->value[$this->htmlListField]) {
         if ($val != 'undefined') {
             $record->{$fieldNameID} = $val;
         }
     }
     $record->write();
 }
开发者ID:prostart,项目名称:cobblestonepath,代码行数:12,代码来源:HasOneComplexTableField.php


示例11: saveInto

 public function saveInto(\DataObjectInterface $record)
 {
     $fieldname = $this->name;
     $relation = $fieldname && $record && $record->hasMethod($fieldname) ? $record->{$fieldname}() : null;
     $value = $this->dataValue();
     if ($relation) {
         // TODO: Save to relation
     } else {
         if (is_array($value)) {
             $this->value = json_encode(array_values($value));
         }
     }
     parent::saveInto($record);
 }
开发者ID:lekoala,项目名称:silverstripe-form-extras,代码行数:14,代码来源:TableFieldCommon.php


示例12: __construct

 /**
  * @param string $name
  * @param string $title
  * @param DataObjectInterface $object
  * @param string $sort
  * @param SS_List $source
  * @param string $titleField
  */
 public function __construct($name, $title, DataObjectInterface $object, $sort = false, SS_List $source = null, $titleField = 'Title')
 {
     $this->setSort($sort);
     if ($object->many_many($name)) {
         $dataSource = $object->{$name}();
         // Check if we're dealing with an UnsavedRelationList
         $unsaved = $dataSource instanceof UnsavedRelationList;
         // Store the relation's class name
         $class = $dataSource->dataClass();
         $this->dataClass = $class;
         // Sort the items
         if ($this->getSort()) {
             $dataSource = $dataSource->sort($this->getSort());
         }
         // If we're dealing with an UnsavedRelationList, it'll be empty, so we
         // can skip this and just use an array of all available items
         if ($unsaved) {
             $dataSource = $class::get()->map()->toArray();
         } else {
             // If we've been given a list source, filter on those IDs only.
             if ($source) {
                 $dataSource = $dataSource->filter('ID', $source->column('ID'));
             }
             // Start building the data source from scratch. Currently selected items first,
             // in the correct sort order
             $dataSource = $dataSource->map('ID', $titleField)->toArray();
             // Get the other items
             $theRest = $class::get();
             // Exclude items that we've already found
             if (!empty($dataSource)) {
                 $theRest = $theRest->exclude('ID', array_keys($dataSource));
             }
             // If we've been given a list source, filter on those IDs only
             if ($source) {
                 $theRest = $theRest->filter('ID', $source->column('ID'));
             }
             $theRest = $theRest->map('ID', $titleField)->toArray();
             // ... we then add the remaining items in whatever order they come
             $dataSource = $dataSource + $theRest;
         }
     } elseif ($source instanceof SS_List) {
         $dataSource = $source->map('ID', $titleField)->toArray();
     } elseif (is_array($source) && ArrayLib::is_associative($source)) {
         $dataSource = $source;
     } else {
         user_error('MultiSelectField::__construct(): MultiSelectField only supports many-to-many relations');
     }
     parent::__construct($name, $title, $dataSource, '', null, true);
 }
开发者ID:helpfulrobot,项目名称:fullscreeninteractive-silverstripe-multiselectfield,代码行数:57,代码来源:MultiSelectField.php


示例13: saveInto

 /**
  * 30/06/2009 - Enhancement:
  * SaveInto checks if set-methods are available and use them
  * instead of setting the values in the money class directly. saveInto
  * initiates a new Money class object to pass through the values to the setter
  * method.
  *
  */
 function saveInto(DataObjectInterface $dataObject)
 {
     $fieldName = $this->name;
     if ($dataObject->hasMethod("set{$fieldName}")) {
         $dataObject->{$fieldName} = DBField::create_field('WTLink', array("Type" => $this->fieldType->Value(), "Internal" => $this->internalField->Value(), "External" => $this->externalField->Value(), "Email" => $this->emailField->Value(), "File" => $this->fileField->Value(), "TargetBlank" => $this->targetBlankField->Value()));
     } else {
         if (!empty($dataObject->{$fieldName})) {
             $dataObject->{$fieldName}->setType($this->fieldType->Value());
             $dataObject->{$fieldName}->setInternal($this->internalField->Value());
             $dataObject->{$fieldName}->setExternal($this->externalField->Value());
             $dataObject->{$fieldName}->setEmail($this->emailField->Value());
             $dataObject->{$fieldName}->setFile($this->fileField->Value());
             $dataObject->{$fieldName}->setTargetBlank($this->targetBlankField->Value());
         }
     }
 }
开发者ID:helpfulrobot,项目名称:webtorque7-link-field,代码行数:24,代码来源:WTLinkField.php


示例14: handleSave

 /**
  * Called when a grid field is saved, converts the StatefulGridFieldList to a RelationList
  * @param {GridField} $field
  * @param {DataObjectInterface} $record
  */
 public function handleSave(GridField $grid, DataObjectInterface $record)
 {
     $list = $grid->getList();
     if ($list instanceof StatefulGridFieldList) {
         $relationName = $list->getRelationName();
         if ($record->has_many($relationName)) {
             $list->changeToList($record->getComponents($list->getRelationName()));
         } else {
             if ($record->many_many($relationName)) {
                 $list->changeToList($record->getManyManyComponents($list->getRelationName()));
             } else {
                 throw new InvalidArgumentException('Record does not have a has_many or many_many relationship called "' . $relationName . '"', null, null);
             }
         }
     }
 }
开发者ID:helpfulrobot,项目名称:webbuilders-group-silverstripe-statefulunsavedlist,代码行数:21,代码来源:StatefulGridFieldListSaveHandler.php


示例15: __construct

 public function __construct($controller, $name, DataObjectInterface $object)
 {
     $this->object = $object;
     $fields = $object->getFrontEndFields(array(get_class($object) => $object));
     $fields->push(new HiddenField("ID", "ID"));
     $actions = new FieldList(new FormAction("save", "Save " . $object->i18n_singular_name()));
     parent::__construct($controller, $name, $fields, $actions);
     $object->extend('updateEditComponentForm', $this);
     if ($this->object->isInDB()) {
         $this->loadDataFrom($this->object);
     }
     //all fields are required
     if (!$this->validator) {
         $this->setValidator(new RequiredFields(array_keys($fields->saveableFields())));
     }
 }
开发者ID:helpfulrobot,项目名称:burnbright-silverstripe-componenteditor,代码行数:16,代码来源:EditComponentForm.php


示例16: saveInto

 public function saveInto(DataObjectInterface $record)
 {
     if ($record->hasField($this->name) && $record->escapeTypeForField($this->name) != 'xml') {
         throw new Exception('HtmlEditorField->saveInto(): This field should save into a HTMLText or HTMLVarchar field.');
     }
     $htmlValue = Injector::inst()->create('HTMLValue', $this->value);
     // Sanitise if requested
     if ($this->config()->sanitise_server_side) {
         $santiser = Injector::inst()->create('HtmlEditorSanitiser', HtmlEditorConfig::get_active());
         $santiser->sanitise($htmlValue);
     }
     // Resample images and add default attributes
     if ($images = $htmlValue->getElementsByTagName('img')) {
         foreach ($images as $img) {
             // strip any ?r=n data from the src attribute
             $img->setAttribute('src', preg_replace('/([^\\?]*)\\?r=[0-9]+$/i', '$1', $img->getAttribute('src')));
             // Resample the images if the width & height have changed.
             if ($image = File::find(urldecode(Director::makeRelative($img->getAttribute('src'))))) {
                 $width = (int) $img->getAttribute('width');
                 $height = (int) $img->getAttribute('height');
                 if ($width && $height && ($width != $image->getWidth() || $height != $image->getHeight())) {
                     //Make sure that the resized image actually returns an image:
                     $resized = $image->ResizedImage($width, $height);
                     if ($resized) {
                         $img->setAttribute('src', $resized->getRelativePath());
                     }
                 }
             }
             // Add default empty title & alt attributes.
             if (!$img->getAttribute('alt')) {
                 $img->setAttribute('alt', '');
             }
             if (!$img->getAttribute('title')) {
                 $img->setAttribute('title', '');
             }
             // Use this extension point to manipulate images inserted using TinyMCE, e.g. add a CSS class, change default title
             // $image is the image, $img is the DOM model
             $this->extend('processImage', $image, $img);
         }
     }
     // optionally manipulate the HTML after a TinyMCE edit and prior to a save
     $this->extend('processHTML', $htmlValue);
     // Store into record
     $record->{$this->name} = $htmlValue->getContent();
 }
开发者ID:hpeide,项目名称:silverstripe-framework,代码行数:45,代码来源:HtmlEditorField.php


示例17: saveInto

 public function saveInto(DataObjectInterface $record)
 {
     if ($record->hasField($this->name) && $record->escapeTypeForField($this->name) != 'xml') {
         throw new Exception('HtmlEditorField->saveInto(): This field should save into a HTMLText or HTMLVarchar field.');
     }
     // Resample images
     $value = Image::regenerate_html_links($this->value);
     $htmlValue = Injector::inst()->create('HTMLValue', $value);
     // Sanitise if requested
     if ($this->config()->sanitise_server_side) {
         $santiser = Injector::inst()->create('HtmlEditorSanitiser', HtmlEditorConfig::get_active());
         $santiser->sanitise($htmlValue);
     }
     // optionally manipulate the HTML after a TinyMCE edit and prior to a save
     $this->extend('processHTML', $htmlValue);
     // Store into record
     $record->{$this->name} = $htmlValue->getContent();
 }
开发者ID:ivoba,项目名称:silverstripe-framework,代码行数:18,代码来源:HtmlEditorField.php


示例18: saveInto

 /**
  * SaveInto checks if set-methods are available and use them instead of setting the values directly. saveInto
  * initiates a new LinkField class object to pass through the values to the setter method.
  */
 public function saveInto(DataObjectInterface $dataObject)
 {
     $db_field = $dataObject->dbObject($this->name);
     $type = $this->composite_fields['Type']->Value();
     $db_field->setLinkType($type);
     if (isset($this->composite_fields[$type])) {
         $db_field->setLinkValue($this->composite_fields[$type]->Value());
     }
 }
开发者ID:helpfulrobot,项目名称:briceburg-silverstripe-flexilink,代码行数:13,代码来源:FlexiLinkField.php


示例19: saveInto

 public function saveInto(DataObjectInterface $record)
 {
     if ($this->name) {
         $tags = explode(',', $this->dataValue());
         if (!$record instanceof SummitEvent) {
             return;
         }
         $record->Tags()->removeAll();
         foreach ($tags as $t) {
             $tag = Tag::get()->filter('Tag', $t)->first();
             if (is_null($tag)) {
                 $tag = Tag::create(array('Tag' => $t));
                 $tag->write();
             }
             $record->Tags()->add($tag);
         }
     }
 }
开发者ID:OpenStackweb,项目名称:openstack-org,代码行数:18,代码来源:TagManagerField.php


示例20: saveInto

 /**
  * @param DataObjectInterface $record
  * @return $this|void
  * if ColorPicker field exists, then convert the value hex to rgb
  */
 public function saveInto(DataObjectInterface $record)
 {
     $name = $this->getName();
     if ($this->ColorPickerExists() && $record->db($name)) {
         $record->{"{$name}"} = $this->value ? 'rgb(' . implode(',', $this->hex2rgb($this->value)) . ')' : null;
     } elseif ($record->db($name)) {
         $record->{"{$name}"} = $this->value;
     }
     return $this;
 }
开发者ID:helpfulrobot,项目名称:mademedia-silverstripe-cloudinary,代码行数:15,代码来源:CloudinaryColorSelectField.php



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
PHP DataObjectSet类代码示例发布时间:2022-05-23
下一篇:
PHP DataObjectGridCellProvider类代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap