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


PHP DataObjectSet::map方法代码示例

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


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

示例1: array

 /**
  * Creates a new optionset field.
  * @param name The field name
  * @param title The field title
  * @param source DataObjectSet
  * @param value The current value
  * @param form The parent form
  */
 function __construct($name, $title = "", $addresses = null, $value = "", $form = null)
 {
     $this->addresses = $addresses;
     $source = array();
     if ($this->addresses) {
         $source = $this->addresses->map("ID", "FullString");
     }
     parent::__construct($name, $title, $source, $value, $form);
 }
开发者ID:nieku,项目名称:silverstripe-ecommerce,代码行数:17,代码来源:SelectOrderAddressField.php

示例2: getCMSFields

 function getCMSFields()
 {
     if ($this->FolderID) {
         // New token - select file:
         $folder = DataObject::get_by_id('Folder', $this->FolderID);
         $files = new DataObjectSet();
         if ($folder->myChildren()) {
             foreach ($folder->myChildren() as $file) {
                 if (!$file instanceof Folder) {
                     $files->push($file);
                 }
             }
             $files->sort('Name');
         }
         $fileField = new DropdownField('FileID', 'File', $files->map('ID', 'Name'));
     } else {
         // Existing token:
         $fileField = new ReadonlyField('FileDummy', 'File', $this->File()->Name);
     }
     $fields = new FieldSet();
     $fields->push($root = new TabSet('Root'));
     $root->push($main = new Tab('Main'));
     $main->push($fileField);
     if (ClassInfo::exists('DatetimeField')) {
         // 2.4.x
         $main->push($expiry_field = new DatetimeField('Expiry', 'Expiry'));
         $expiry_field->getDateField()->setConfig('showcalendar', true);
         $expiry_field->getTimeField()->setConfig('showdropdown', true);
     } else {
         // 2.3.x
         $main->push($expiry_field = new PopupDateTimeField('Expiry', 'Expiry'));
     }
     $main->push(new ReadonlyField('MemberDummyField', 'Member', $this->MemberNice()));
     if ($this->ID) {
         $main->push(new ReadonlyField('Token', 'Token'));
     }
     $this->extend('updateCMSFields', $fields);
     return $fields;
 }
开发者ID:hamishcampbell,项目名称:silverstripe-securefiles,代码行数:39,代码来源:SecureFileAccessToken.php

示例3: checkNewsPageDataObjectSet

 private function checkNewsPageDataObjectSet(DataObjectSet $newsPages, array $expectedURLSegments)
 {
     $actualURLSegments = array_values($newsPages->map('ID', 'URLSegment'));
     $this->assertEquals($expectedURLSegments, $actualURLSegments);
 }
开发者ID:redema,项目名称:silverstripe-news,代码行数:5,代码来源:NewsHolderTest.php

示例4: options

 /**
  * Get options for a product and return for use in the form
  * Must get options for nextAttributeID, but these options should be filtered so 
  * that only the options for the variations that match attributeID and optionID
  * are returned.
  * 
  * In other words, do not just return options for a product, return options for product
  * variations.
  * 
  * Usually called via AJAX.
  * 
  * @param SS_HTTPRequest $request
  * @return String JSON encoded string for use to update options in select fields on Product page
  */
 public function options(SS_HTTPRequest $request)
 {
     $data = array();
     $product = $this->data();
     $options = new DataObjectSet();
     $variations = $product->Variations();
     $filteredVariations = new DataObjectSet();
     $attributeOptions = $request->postVar('Options');
     $nextAttributeID = $request->postVar('NextAttributeID');
     //Filter variations to match attribute ID and option ID
     //Variations need to have the same option for each attribute ID in POST data to be considered
     if ($variations && $variations->exists()) {
         foreach ($variations as $variation) {
             $variationOptions = array();
             //if ($attributeOptions && is_array($attributeOptions)) {
             foreach ($attributeOptions as $attributeID => $optionID) {
                 //Get option for attribute ID, if this variation has options for every attribute in the array then add it to filtered
                 $attributeOption = $variation->getOptionForAttribute($attributeID);
                 if ($attributeOption && $attributeOption->ID == $optionID) {
                     $variationOptions[$attributeID] = $optionID;
                 }
             }
             //}
             if ($variationOptions == $attributeOptions && $variation->isEnabled()) {
                 $filteredVariations->push($variation);
             }
         }
     }
     //Find options in filtered variations that match next attribute ID
     //All variations must have options for all attributes so this is belt and braces really
     if ($filteredVariations && $filteredVariations->exists()) {
         foreach ($filteredVariations as $variation) {
             $attributeOption = $variation->getOptionForAttribute($nextAttributeID);
             if ($attributeOption) {
                 $options->push($attributeOption);
             }
         }
     }
     if ($options && $options->exists()) {
         $map = $options->map();
         //This resets the array counter to 0 which ruins the attribute IDs
         //array_unshift($map, 'Please Select');
         $data['options'] = $map;
         $data['count'] = count($map);
         $data['nextAttributeID'] = $nextAttributeID;
     }
     return json_encode($data);
 }
开发者ID:helpfulrobot,项目名称:swipestripe-swipestripe,代码行数:62,代码来源:Product.php

示例5: findIdenticalItem

 /**
  * Find an identical item in the order/cart, item is identical if the 
  * productID, version and the options for the item are the same. Used to increase 
  * quantity of items that already exist in the cart/Order.
  * 
  * @see Order::addItem()
  * @param DatObject $product
  * @param DataObjectSet $productOptions
  * @return DataObject
  */
 function findIdenticalItem($product, DataObjectSet $productOptions)
 {
     foreach ($this->Items() as $item) {
         if ($item->ObjectID == $product->ID && $item->ObjectVersion == $product->Version) {
             $productOptionsMap = array();
             $existingOptionsMap = array();
             if ($productOptions) {
                 $productOptionsMap = $productOptions->map('ID', 'Version');
             }
             if ($item) {
                 foreach ($item->ItemOptions() as $itemOption) {
                     $productOption = $itemOption->Object();
                     $existingOptionsMap[$productOption->ID] = $productOption->Version;
                 }
             }
             if ($productOptionsMap == $existingOptionsMap) {
                 return $item;
             }
         }
     }
 }
开发者ID:helpfulrobot,项目名称:swipestripe-swipestripe,代码行数:31,代码来源:Order.php


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