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


PHP ArrayList::map方法代码示例

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


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

示例1: testSources

 /**
  * Test different data sources
  */
 public function testSources()
 {
     // Array
     $items = array('a' => 'Apple', 'b' => 'Banana', 'c' => 'Cranberry');
     $field = new CheckboxSetField('Field', null, $items);
     $this->assertEquals($items, $field->getSource());
     // SS_List
     $list = new ArrayList(array(new ArrayData(array('ID' => 'a', 'Title' => 'Apple')), new ArrayData(array('ID' => 'b', 'Title' => 'Banana')), new ArrayData(array('ID' => 'c', 'Title' => 'Cranberry'))));
     $field2 = new CheckboxSetField('Field', null, $list);
     $this->assertEquals($items, $field2->getSource());
     $field3 = new CheckboxSetField('Field', null, $list->map());
     $this->assertEquals($items, $field3->getSource());
 }
开发者ID:assertchris,项目名称:silverstripe-framework,代码行数:16,代码来源:CheckboxSetFieldTest.php

示例2: getPrintURLForMany

 /**
  * Returns the print URL for the given DataObject
  * (silvercart-print/$DataObjectName/$DataObjectID)
  *
  * @param ArrayList $dataObjectList ArrayList to get print URL for
  * 
  * @return string 
  */
 public static function getPrintURLForMany($dataObjectList)
 {
     $printURL = '';
     if ($dataObjectList instanceof SS_List) {
         $dataObject = $dataObjectList->first();
         if ($dataObject instanceof DataObject) {
             $map = $dataObjectList->map('ID', 'ID');
             if ($map instanceof SS_Map) {
                 $map = $map->toArray();
             }
             $printURL = sprintf('silvercart-print-many/%s/%s', $dataObject->ClassName, implode('-', $map));
         }
     }
     return $printURL;
 }
开发者ID:silvercart,项目名称:silvercart,代码行数:23,代码来源:SilvercartPrint.php

示例3: getTeamsDLL

 public function getTeamsDLL($id = 'add_member_team')
 {
     $current_member = Member::currentUser();
     if (!$current_member) {
         return false;
     }
     $company = $current_member->getManagedCCLACompany();
     if (!$company) {
         return false;
     }
     $res = $this->team_repository->getByCompany($company->getIdentifier());
     $res = new ArrayList($res);
     $ddl = new DropdownField($id, null, $res->map("ID", "Name"));
     $ddl->setEmptyString('-- Select a Team --');
     return $ddl;
 }
开发者ID:OpenStackweb,项目名称:openstack-org,代码行数:16,代码来源:EditProfilePageICLAExtension.php

示例4: map_in_groups

 /**
  * Get a member SQLMap of members in specific groups
  * 
  * If no $groups is passed, all members will be returned
  * 
  * @param mixed $groups - takes a SS_List, an array or a single Group.ID
  * @return SQLMap Returns an SQLMap that returns all Member data.
  * @see map()
  */
 public static function map_in_groups($groups = null)
 {
     $groupIDList = array();
     if ($groups instanceof SS_List) {
         foreach ($groups as $group) {
             $groupIDList[] = $group->ID;
         }
     } elseif (is_array($groups)) {
         $groupIDList = $groups;
     } elseif ($groups) {
         $groupIDList[] = $groups;
     }
     // No groups, return all Members
     if (!$groupIDList) {
         return Member::get()->sort(array('Surname' => 'ASC', 'FirstName' => 'ASC'))->map();
     }
     $membersList = new ArrayList();
     // This is a bit ineffective, but follow the ORM style
     foreach (Group::get()->byIDs($groupIDList) as $group) {
         $membersList->merge($group->Members());
     }
     $membersList->removeDuplicates('ID');
     return $membersList->map();
 }
开发者ID:hemant-chakka,项目名称:awss,代码行数:33,代码来源:Member.php

示例5: testMap

 public function testMap()
 {
     $list = new ArrayList(array(array('ID' => 1, 'Name' => 'Steve'), (object) array('ID' => 3, 'Name' => 'Bob'), array('ID' => 5, 'Name' => 'John')));
     $this->assertEquals($list->map('ID', 'Name'), array(1 => 'Steve', 3 => 'Bob', 5 => 'John'));
 }
开发者ID:maent45,项目名称:redefine_renos,代码行数:5,代码来源:ArrayListTest.php

示例6: getCMSFields

 /**
  * @return FieldList
  */
 public function getCMSFields()
 {
     // Determine optional field values
     $form = $this->getFormParent();
     // predefined choices are also candidates
     $multiOptionFields = EditableMultipleOptionField::get()->filter('ParentID', $form->ID);
     // if they have email fields then we could send from it
     $validEmailFromFields = EditableEmailField::get()->filter('ParentID', $form->ID);
     // For the subject, only one-line entry boxes make sense
     $validSubjectFields = EditableTextField::get()->filter('ParentID', $form->ID)->filterByCallback(function ($item, $list) {
         return (int) $item->getSetting('Rows') === 1;
     });
     $validSubjectFields->merge($multiOptionFields);
     // To address can only be email fields or multi option fields
     $validEmailToFields = new ArrayList($validEmailFromFields->toArray());
     $validEmailToFields->merge($multiOptionFields);
     // Build fieldlist
     $fields = FieldList::create(Tabset::create('Root')->addExtraClass('EmailRecipientForm'));
     // Configuration fields
     $fields->addFieldsToTab('Root.EmailDetails', array(FieldGroup::create(TextField::create('EmailSubject', _t('UserDefinedForm.TYPESUBJECT', 'Type subject'))->setAttribute('style', 'min-width: 400px;'), DropdownField::create('SendEmailSubjectFieldID', _t('UserDefinedForm.SELECTAFIELDTOSETSUBJECT', '.. or select a field to use as the subject'), $validSubjectFields->map('ID', 'Title'))->setEmptyString(''))->setTitle(_t('UserDefinedForm.EMAILSUBJECT', 'Email subject')), FieldGroup::create(TextField::create('EmailAddress', _t('UserDefinedForm.TYPETO', 'Type to address'))->setAttribute('style', 'min-width: 400px;'), DropdownField::create('SendEmailToFieldID', _t('UserDefinedForm.ORSELECTAFIELDTOUSEASTO', '.. or select a field to use as the to address'), $validEmailToFields->map('ID', 'Title'))->setEmptyString(' '))->setTitle(_t('UserDefinedForm.SENDEMAILTO', 'Send email to'))->setDescription(_t('UserDefinedForm.SENDEMAILTO_DESCRIPTION', 'You may enter multiple email addresses as a comma separated list.')), TextField::create('EmailFrom', _t('UserDefinedForm.FROMADDRESS', 'Send email from'))->setDescription(_t('UserDefinedForm.EmailFromContent', "The from address allows you to set who the email comes from. On most servers this " . "will need to be set to an email address on the same domain name as your site. " . "For example on yoursite.com the from address may need to be something@yoursite.com. " . "You can however, set any email address you wish as the reply to address.")), FieldGroup::create(TextField::create('EmailReplyTo', _t('UserDefinedForm.TYPEREPLY', 'Type reply address'))->setAttribute('style', 'min-width: 400px;'), DropdownField::create('SendEmailFromFieldID', _t('UserDefinedForm.ORSELECTAFIELDTOUSEASFROM', '.. or select a field to use as reply to address'), $validEmailFromFields->map('ID', 'Title'))->setEmptyString(' '))->setTitle(_t('UserDefinedForm.REPLYADDRESS', 'Email for reply to'))->setDescription(_t('UserDefinedForm.REPLYADDRESS_DESCRIPTION', 'The email address which the recipient is able to \'reply\' to.'))));
     // Only show the preview link if the recipient has been saved.
     if (!empty($this->EmailTemplate)) {
         $preview = sprintf('<p><a href="%s" target="_blank" class="ss-ui-button">%s</a></p><em>%s</em>', "admin/pages/edit/EditForm/field/EmailRecipients/item/{$this->ID}/preview", _t('UserDefinedForm.PREVIEW_EMAIL', 'Preview email'), _t('UserDefinedForm.PREVIEW_EMAIL_DESCRIPTION', 'Note: Unsaved changes will not appear in the preview.'));
     } else {
         $preview = sprintf('<em>%s</em>', _t('UserDefinedForm.PREVIEW_EMAIL_UNAVAILABLE', 'You can preview this email once you have saved the Recipient.'));
     }
     // Email templates
     $fields->addFieldsToTab('Root.EmailContent', array(new CheckboxField('HideFormData', _t('UserDefinedForm.HIDEFORMDATA', 'Hide form data from email?')), new CheckboxField('SendPlain', _t('UserDefinedForm.SENDPLAIN', 'Send email as plain text? (HTML will be stripped)')), new DropdownField('EmailTemplate', _t('UserDefinedForm.EMAILTEMPLATE', 'Email template'), $this->getEmailTemplateDropdownValues()), new HTMLEditorField('EmailBodyHtml', _t('UserDefinedForm.EMAILBODYHTML', 'Body')), new TextareaField('EmailBody', _t('UserDefinedForm.EMAILBODY', 'Body')), new LiteralField('EmailPreview', '<div id="EmailPreview">' . $preview . '</div>')));
     // Custom rules for sending this field
     $grid = new GridField("CustomRules", _t('EditableFormField.CUSTOMRULES', 'Custom Rules'), $this->CustomRules(), $this->getRulesConfig());
     $grid->setDescription(_t('UserDefinedForm.RulesDescription', 'Emails will only be sent to the recipient if the custom rules are met. If no rules are defined, this receipient will receive notifications for every submission.'));
     $fields->addFieldsToTab('Root.CustomRules', array(new DropdownField('CustomRulesCondition', _t('UserDefinedForm.SENDIF', 'Send condition'), array('Or' => 'Any conditions are true', 'And' => 'All conditions are true')), $grid));
     $this->extend('updateCMSFields', $fields);
     return $fields;
 }
开发者ID:sekjal,项目名称:silverstripe-userforms,代码行数:38,代码来源:UserDefinedForm.php

示例7: 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 ArrayList $options
  * @return DataObject
  */
 public function findIdenticalItem($product, $variation, ArrayList $options)
 {
     $items = $this->Items();
     $filtered = $items->filter(array('ProductID' => $product->ID, 'ProductVersion' => $product->Version));
     if ($variation && $variation->exists()) {
         $filtered = $filtered->filter(array('VariationID' => $variation->ID, 'VariationVersion' => $variation->Version));
     }
     //Could have many products of same variation at this point, need to check product options carefully
     $optionsMap = $options->map('Description', 'Price');
     $existingItems = clone $filtered;
     foreach ($existingItems as $existingItem) {
         $existingOptionsMap = $existingItem->ItemOptions()->map('Description', 'Price')->toArray();
         if ($optionsMap != $existingOptionsMap) {
             $filtered = $filtered->exclude('ID', $existingItem->ID);
         }
     }
     return $filtered->first();
 }
开发者ID:vinstah,项目名称:body,代码行数:28,代码来源:Order.php

示例8: getCMSFields

 /**
  * @return FieldList
  */
 public function getCMSFields()
 {
     $fields = new FieldList(new TextField('EmailSubject', _t('UserDefinedForm.EMAILSUBJECT', 'Email subject')), new LiteralField('EmailFromContent', '<p>' . _t('UserDefinedForm.EmailFromContent', "The from address allows you to set who the email comes from. On most servers this " . "will need to be set to an email address on the same domain name as your site. " . "For example on yoursite.com the from address may need to be something@yoursite.com. " . "You can however, set any email address you wish as the reply to address.") . "</p>"), new TextField('EmailFrom', _t('UserDefinedForm.FROMADDRESS', 'Send email from')), new TextField('EmailReplyTo', _t('UserDefinedForm.REPLYADDRESS', 'Email for reply to')), new TextField('EmailAddress', _t('UserDefinedForm.SENDEMAILTO', 'Send email to')), new CheckboxField('HideFormData', _t('UserDefinedForm.HIDEFORMDATA', 'Hide form data from email?')), new CheckboxField('SendPlain', _t('UserDefinedForm.SENDPLAIN', 'Send email as plain text? (HTML will be stripped)')), new TextareaField('EmailBody', _t('UserDefinedForm.EMAILBODY', 'Body')));
     $formID = $this->FormID != 0 ? $this->FormID : Session::get('CMSMain.currentPage');
     $dropdowns = array();
     // if they have email fields then we could send from it
     $validEmailFields = EditableEmailField::get()->filter('ParentID', (int) $formID);
     // for the subject, only one-line entry boxes make sense
     $validSubjectFields = EditableTextField::get()->filter('ParentID', (int) $formID)->filterByCallback(function ($item, $list) {
         return (int) $item->getSetting('Rows') === 1;
     });
     // predefined choices are also candidates
     $multiOptionFields = EditableMultipleOptionField::get()->filter('ParentID', (int) $formID);
     $fields->insertAfter($dropdowns[] = new DropdownField('SendEmailFromFieldID', _t('UserDefinedForm.ORSELECTAFIELDTOUSEASFROM', '.. or select a field to use as reply to address'), $validEmailFields->map('ID', 'Title')), 'EmailReplyTo');
     $validEmailFields = new ArrayList($validEmailFields->toArray());
     $validEmailFields->merge($multiOptionFields);
     $validSubjectFields->merge($multiOptionFields);
     $fields->insertAfter($dropdowns[] = new DropdownField('SendEmailToFieldID', _t('UserDefinedForm.ORSELECTAFIELDTOUSEASTO', '.. or select a field to use as the to address'), $validEmailFields->map('ID', 'Title')), 'EmailAddress');
     $fields->insertAfter($dropdowns[] = new DropdownField('SendEmailSubjectFieldID', _t('UserDefinedForm.SELECTAFIELDTOSETSUBJECT', '.. or select a field to use as the subject'), $validSubjectFields->map('ID', 'Title')), 'EmailSubject');
     foreach ($dropdowns as $dropdown) {
         $dropdown->setHasEmptyDefault(true);
         $dropdown->setEmptyString(" ");
     }
     $this->extend('updateCMSFields', $fields);
     return $fields;
 }
开发者ID:8secs,项目名称:cocina,代码行数:29,代码来源:UserDefinedForm.php

示例9: testMap

 public function testMap()
 {
     $list = new ArrayList(array(array('ID' => 1, 'Name' => 'Steve'), (object) array('ID' => 3, 'Name' => 'Bob'), array('ID' => 5, 'Name' => 'John')));
     $map = $list->map('ID', 'Name');
     // Items added after calling map should not be included retroactively
     $list->add(array('ID' => 7, 'Name' => 'Andrew'));
     $this->assertInstanceOf('SS_Map', $map);
     $this->assertEquals(array(1 => 'Steve', 3 => 'Bob', 5 => 'John'), $map->toArray());
 }
开发者ID:assertchris,项目名称:silverstripe-framework,代码行数:9,代码来源:ArrayListTest.php


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