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


PHP ArrayList::toArray方法代码示例

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


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

示例1: getInheritedSchemas

 /**
  * If this is attached to an object with the hierarchy extension, it returns
  * a set of a schema objects attached to any ancestors (which should be
  * present on this object).
  *
  * @return ArrayList
  */
 public function getInheritedSchemas()
 {
     $result = new ArrayList();
     if (!$this->owner->hasExtension('Hierarchy')) {
         return new ArrayList();
     }
     $ids = array();
     $parents = $this->owner->getAncestors();
     foreach ($parents as $parent) {
         $ids[] = $parent->ID;
     }
     if (count($ids)) {
         $filter = sprintf('"MetadataSchema"."ID" = "MetadataSchemaLink"."SchemaID"' . ' AND "MetadataSchemaLink"."ParentClass" = \'%s\'' . ' AND "MetadataSchemaLink"."ParentID" IN (%s)', ClassInfo::baseDataClass($this->owner->class), implode(', ', $ids));
         $result = MetadataSchema::get()->innerJoin('MetadataSchemaLink', $filter);
         if ($result) {
             $result = new ArrayList($result->toArray());
         } else {
             $result = new ArrayList();
         }
     }
     if ($this->owner instanceof SiteTree) {
         // Check SiteConfig too
         $config = SiteConfig::current_site_config();
         if ($config->hasExtension('MetadataExtension')) {
             $schemas = $config->getAttachedSchemas();
             if ($schemas && $schemas->count()) {
                 $result->merge($schemas);
             }
         }
     }
     return $result;
 }
开发者ID:phill-m,项目名称:silverstripe-metadata,代码行数:39,代码来源:MetadataExtension.php

示例2: updateRelatedProducts

 /**
  * @param ManyManyList $products
  */
 public function updateRelatedProducts(&$products, $limit, $random)
 {
     $curCount = $products->count();
     if ($curCount < $limit) {
         $cfg = Config::inst()->forClass(get_class($this->owner));
         $class = $cfg->get('related_products_class');
         // look up the fields
         $fields = $cfg->get('related_products_fields');
         if (empty($fields)) {
             return;
         }
         if (!is_array($fields)) {
             $fields = array($fields);
         }
         // create a filter from the fields
         $filter = array();
         foreach ($fields as $f) {
             $filter[$f] = $this->owner->getField($f);
         }
         // Convert to an array list so we can add to it
         $products = new ArrayList($products->toArray());
         // Look up products that match the filter
         $generated = DataObject::get($class)->filterAny($filter)->exclude('ID', $this->owner->ID)->sort('RAND()')->limit($limit - $curCount);
         foreach ($generated as $prod) {
             $products->push($prod);
         }
     }
 }
开发者ID:markguinn,项目名称:silverstripe-related_products,代码行数:31,代码来源:HasGeneratedRelatedProducts.php

示例3: sort

 /**
  * Sorts the specified list according to the order induced by the specified comparator. All elements in the list
  * must be mutually comparable.
  *
  * @param ArrayList $list
  * @param Comparator $comparator
  * @return ArrayList
  */
 public static function sort(ArrayList &$list, Comparator $comparator)
 {
     $array = $list->toArray();
     usort($array, [$comparator, "compare"]);
     $list->replace($array);
     return $list;
 }
开发者ID:seboettg,项目名称:collection,代码行数:15,代码来源:Collections.php

示例4: Breadcrumbs

 /**
  * @return ArrayList
  */
 public function Breadcrumbs($unlinked = false)
 {
     $defaultTitle = LeftAndMain::menu_title_for_class('CodeBankIPAgreement');
     $title = _t('CodeBankIPAgreement.MENUTITLE', $defaultTitle);
     $items = new ArrayList(array(new ArrayData(array('Title' => $title, 'Link' => $unlinked ? false : 'admin/codeBank/show/' . $this->currentPageID()))));
     $record = $this->currentPage();
     if ($record && $record->exists()) {
         if ($record->hasExtension('Hierarchy')) {
             $ancestors = $record->getAncestors();
             $ancestors = new ArrayList(array_reverse($ancestors->toArray()));
             $ancestors->push($record);
             foreach ($ancestors as $ancestor) {
                 $items->push(new ArrayData(array('Title' => $ancestor->Title, 'Link' => $unlinked ? false : Controller::join_links($this->Link('show'), $ancestor->ID))));
             }
         } else {
             $items->push(new ArrayData(array('Title' => $record->Title, 'Link' => $unlinked ? false : Controller::join_links($this->Link('show'), $record->ID))));
         }
     }
     return $items;
 }
开发者ID:helpfulrobot,项目名称:undefinedoffset-silverstripe-codebank,代码行数:23,代码来源:CodeBankIPAgreement.php

示例5: Items

	/**
	 * Displays the items from {@link sourceItems()} using the encapsulation object.
	 * If the field value has been set as an array (e.g. after a failed validation),
	 * it generates the rows from array data instead.
	 * Used in the formfield template to iterate over each row.
	 * 
	 * @return SS_List Collection of {@link TableField_Item}
	 */
	function Items() {
		// holds TableField_Item instances
		$items = new ArrayList();

		$sourceItems = $this->sourceItems();

		// either load all rows from the field value,
		// (e.g. when validation failed), or from sourceItems()
		if($this->value) {
			if(!$sourceItems) $sourceItems = new ArrayList();

			// get an array keyed by rows, rather than values
			$rows = $this->sortData(ArrayLib::invert($this->value));
			// ignore all rows which are already saved
			if(isset($rows['new'])) {
				if($sourceItems instanceof DataList) {
					$sourceItems = new ArrayList($sourceItems->toArray());
				}

				$newRows = $this->sortData($rows['new']);
				// iterate over each value (not each row)
				$i = 0;
				foreach($newRows as $idx => $newRow){
					// set a pseudo-ID
					$newRow['ID'] = "new";

					// unset any extradata
					foreach($newRow as $k => $v){
						if($this->extraData && array_key_exists($k, $this->extraData)){
							unset($newRow[$k]);
						}
					}

					// generate a temporary DataObject container (not saved in the database)
					$sourceClass = $this->sourceClass();
					$sourceItems->add(new $sourceClass($newRow));

					$i++;
				}
			}
		} 

		// generate a new TableField_Item instance from each collected item
		if($sourceItems) foreach($sourceItems as $sourceItem) {
			$items->push($this->generateTableFieldItem($sourceItem));
		}

		// add an empty TableField_Item for a single "add row"
		if($this->showAddRow && $this->Can('add')) {
			$items->push(new TableField_Item(null, $this, null, $this->fieldTypes, true));
		}

		return $items;
	}
开发者ID:redema,项目名称:sapphire,代码行数:62,代码来源:TableField.php

示例6: Breadcrumbs

 /**
  * CMS-specific functionality: Passes through navigation breadcrumbs
  * to the template, and includes the currently edited record (if any).
  * see {@link LeftAndMain->Breadcrumbs()} for details.
  *
  * @param boolean $unlinked
  * @return ArrayData
  */
 function Breadcrumbs($unlinked = false)
 {
     if (!$this->popupController->hasMethod('Breadcrumbs')) {
         return;
     }
     $items = $this->popupController->Breadcrumbs($unlinked);
     if ($this->record && $this->record->ID) {
         $ancestors = $this->record->getAncestors();
         $ancestors = new ArrayList(array_reverse($ancestors->toArray()));
         $ancestors->push($this->record);
         // Push each ancestor to breadcrumbs
         foreach ($ancestors as $ancestor) {
             $items->push(new ArrayData(array('Title' => $ancestor->Title, 'Link' => $unlinked ? false : $this->popupController->Link() . "?ParentID={$ancestor->ID}")));
         }
     } else {
         $items->push(new ArrayData(array('Title' => sprintf(_t('GridField.NewRecord', 'New %s'), $this->record->singular_name()), 'Link' => false)));
     }
     return $items;
 }
开发者ID:helpfulrobot,项目名称:i-lateral-silverstripe-catalogue,代码行数:27,代码来源:CatalogueAdmin.php

示例7: Breadcrumbs

 /**
  * @return ArrayList
  */
 public function Breadcrumbs($unlinked = false)
 {
     $title = self::menu_title_for_class($this->class);
     $items = new ArrayList(array(new ArrayData(array('Title' => $title, 'Link' => $unlinked ? false : $this->Link()))));
     $record = $this->currentPage();
     if ($record && $record->exists()) {
         if ($record->hasExtension('Hierarchy')) {
             $ancestors = $record->getAncestors();
             $ancestors = new ArrayList(array_reverse($ancestors->toArray()));
             $ancestors->push($record);
             foreach ($ancestors as $ancestor) {
                 $items->push(new ArrayData(array('Title' => $ancestor->Title, 'Link' => $unlinked ? false : Controller::join_links($this->Link('show'), $ancestor->ID))));
             }
         } else {
             $items->push(new ArrayData(array('Title' => $record->Title, 'Link' => $unlinked ? false : Controller::join_links($this->Link('show'), $record->ID))));
         }
     }
     return $items;
 }
开发者ID:nzjoel,项目名称:sapphire,代码行数:22,代码来源:LeftAndMain.php

示例8: testToArray

 public function testToArray()
 {
     // Remove the following lines when you implement this test.
     $this->assertTrue(\is_array($this->object->toArray()));
 }
开发者ID:robo47,项目名称:BlazeFramework,代码行数:5,代码来源:ArrayListTest.php

示例9: testVFI

 public function testVFI()
 {
     // Given a simple definition, spec should be properly fleshed out
     $spec = VirtualFieldIndex::get_vfi_spec('Product');
     $this->assertEquals('simple', $spec['Price2']['Type']);
     $this->assertEquals('all', $spec['Price2']['DependsOn']);
     $this->assertEquals('sellingPrice', $spec['Price2']['Source']);
     // Given a simple array definition, spec should be properly fleshed out
     $spec = VirtualFieldIndex::get_vfi_spec('Product');
     $this->assertEquals('list', $spec['Category']['Type']);
     $this->assertEquals('all', $spec['Category']['DependsOn']);
     $this->assertEquals('Parent', $spec['Category']['Source'][0]);
     // build the vfi just in case
     VirtualFieldIndex::build('Product');
     $p = $this->objFromFixture('Product', 'p4');
     $cats = new ArrayList(array($this->objFromFixture('ProductCategory', 'c1'), $this->objFromFixture('ProductCategory', 'c2'), $this->objFromFixture('ProductCategory', 'c3')));
     // vfi fields should be present and correct
     $this->assertTrue($p->hasField('VFI_Price'), 'Price index exists');
     $this->assertEquals(5, $p->VFI_Price, 'Price is correct');
     $this->assertTrue($p->hasField('VFI_Category'), 'Category index exists');
     $this->assertEquals('>ProductCategory|' . implode('|', $cats->column('ID')) . '|', $p->VFI_Category, 'Category index is correct');
     // vfi accessors work
     $this->assertEquals(5, $p->getVFI('Price'), 'Simple getter works');
     $this->assertEquals($cats->toArray(), $p->getVFI('Category'), 'List getter works');
     $this->assertNull($p->getVFI('NonExistentField'), 'Non existent field should return null');
 }
开发者ID:hex0id,项目名称:silverstripe-shop-search,代码行数:26,代码来源:ShopSearchTest.php

示例10: accessible_sites

 /**
  * Return the subsites that the current user can access by given permission.
  * Sites will only be included if they have a Title.
  *
  * @param $permCode array|string Either a single permission code or an array of permission codes.
  * @param $includeMainSite If true, the main site will be included if appropriate.
  * @param $mainSiteTitle The label to give to the main site
  * @param $member
  * @return DataList of {@link Subsite} instances
  */
 public static function accessible_sites($permCode, $includeMainSite = true, $mainSiteTitle = "Main site", $member = null)
 {
     // Rationalise member arguments
     if (!$member) {
         $member = Member::currentUser();
     }
     if (!$member) {
         return new ArrayList();
     }
     if (!is_object($member)) {
         $member = DataObject::get_by_id('Member', $member);
     }
     // Rationalise permCode argument
     if (is_array($permCode)) {
         $SQL_codes = "'" . implode("', '", Convert::raw2sql($permCode)) . "'";
     } else {
         $SQL_codes = "'" . Convert::raw2sql($permCode) . "'";
     }
     // Cache handling
     $cacheKey = $SQL_codes . '-' . $member->ID . '-' . $includeMainSite . '-' . $mainSiteTitle;
     if (isset(self::$_cache_accessible_sites[$cacheKey])) {
         return self::$_cache_accessible_sites[$cacheKey];
     }
     $subsites = DataList::create('Subsite')->where("\"Subsite\".\"Title\" != ''")->leftJoin('Group_Subsites', "\"Group_Subsites\".\"SubsiteID\" = \"Subsite\".\"ID\"")->innerJoin('Group', "\"Group\".\"ID\" = \"Group_Subsites\".\"GroupID\" OR \"Group\".\"AccessAllSubsites\" = 1")->innerJoin('Group_Members', "\"Group_Members\".\"GroupID\"=\"Group\".\"ID\" AND \"Group_Members\".\"MemberID\" = {$member->ID}")->innerJoin('Permission', "\"Group\".\"ID\"=\"Permission\".\"GroupID\" AND \"Permission\".\"Code\" IN ({$SQL_codes}, 'CMS_ACCESS_LeftAndMain', 'ADMIN')");
     if (!$subsites) {
         $subsites = new ArrayList();
     }
     $rolesSubsites = DataList::create('Subsite')->where("\"Subsite\".\"Title\" != ''")->leftJoin('Group_Subsites', "\"Group_Subsites\".\"SubsiteID\" = \"Subsite\".\"ID\"")->innerJoin('Group', "\"Group\".\"ID\" = \"Group_Subsites\".\"GroupID\" OR \"Group\".\"AccessAllSubsites\" = 1")->innerJoin('Group_Members', "\"Group_Members\".\"GroupID\"=\"Group\".\"ID\" AND \"Group_Members\".\"MemberID\" = {$member->ID}")->innerJoin('Group_Roles', "\"Group_Roles\".\"GroupID\"=\"Group\".\"ID\"")->innerJoin('PermissionRole', "\"Group_Roles\".\"PermissionRoleID\"=\"PermissionRole\".\"ID\"")->innerJoin('PermissionRoleCode', "\"PermissionRole\".\"ID\"=\"PermissionRoleCode\".\"RoleID\" AND \"PermissionRoleCode\".\"Code\" IN ({$SQL_codes}, 'CMS_ACCESS_LeftAndMain', 'ADMIN')");
     if (!$subsites && $rolesSubsites) {
         return $rolesSubsites;
     }
     $subsites = new ArrayList($subsites->toArray());
     if ($rolesSubsites) {
         foreach ($rolesSubsites as $subsite) {
             if (!$subsites->find('ID', $subsite->ID)) {
                 $subsites->push($subsite);
             }
         }
     }
     if ($includeMainSite) {
         if (!is_array($permCode)) {
             $permCode = array($permCode);
         }
         if (self::hasMainSitePermission($member, $permCode)) {
             $subsites = $subsites->toArray();
             $mainSite = new Subsite();
             $mainSite->Title = $mainSiteTitle;
             array_unshift($subsites, $mainSite);
             $subsites = ArrayList::create($subsites);
         }
     }
     self::$_cache_accessible_sites[$cacheKey] = $subsites;
     return $subsites;
 }
开发者ID:hamaka,项目名称:silverstripe-subsites,代码行数:64,代码来源:Subsite.php

示例11: evalYepnope

 /**
  * Evaluate yepnope conditions and build Javascript to be output in template
  *
  * @return void
  */
 public function evalYepnope($customScriptID)
 {
     $str = "";
     $tests = $this->yepnopeTests->toArray();
     if (empty($tests)) {
         return;
     }
     if ($yepnope = $this->get_yepnope()) {
         Requirements::javascript($yepnope);
     }
     if ($timeout = $this->get_timeout()) {
         $str .= "yepnope.errorTimeout = " . $timeout . ";\n";
     }
     $data = $this->convertToObject($tests);
     $str .= 'yepnope(' . $data . ');';
     Requirements::customScript($str, $customScriptID);
 }
开发者ID:helpfulrobot,项目名称:kinglozzer-yepnopesilverstripe,代码行数:22,代码来源:Yepnope.php

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

示例13: testMultipleExcludeThreeArguments

	/**
	 * $list->exclude(array('Name'=>array('bob','phil'), 'Age'=>array(10, 16), 'HasBananas'=>true));
	 */
	public function testMultipleExcludeThreeArguments() {
		$list = new ArrayList(array(
			0 => array('Name' => 'bob', 'Age' => 10, 'HasBananas'=>false),
			1 => array('Name' => 'phil','Age' => 11, 'HasBananas'=>true),
			2 => array('Name' => 'bob', 'Age' => 12, 'HasBananas'=>true),
			3 => array('Name' => 'phil','Age' => 12, 'HasBananas'=>true),
			4 => array('Name' => 'bob', 'Age' => 14, 'HasBananas'=>false),
			4 => array('Name' => 'ann', 'Age' => 14, 'HasBananas'=>true),
			5 => array('Name' => 'phil','Age' => 14, 'HasBananas'=>false),
			6 => array('Name' => 'bob', 'Age' => 16, 'HasBananas'=>false),
			7 => array('Name' => 'phil','Age' => 16, 'HasBananas'=>true),
			8 => array('Name' => 'clair','Age' => 16, 'HasBananas'=>true)
		));

		$list->exclude(array('Name'=>array('bob','phil'),'Age'=>array(10, 16),'HasBananas'=>true));
		$expected = array(
			0 => array('Name' => 'bob', 'Age' => 10, 'HasBananas'=>false),
			1 => array('Name' => 'phil','Age' => 11, 'HasBananas'=>true),
			2 => array('Name' => 'bob', 'Age' => 12, 'HasBananas'=>true),
			3 => array('Name' => 'phil','Age' => 12, 'HasBananas'=>true),
			4 => array('Name' => 'bob', 'Age' => 14, 'HasBananas'=>false),
			4 => array('Name' => 'ann', 'Age' => 14, 'HasBananas'=>true),
			5 => array('Name' => 'phil','Age' => 14, 'HasBananas'=>false),
			6 => array('Name' => 'bob', 'Age' => 16, 'HasBananas'=>false),
			8 => array('Name' => 'clair','Age' => 16, 'HasBananas'=>true)
		);
		$this->assertEquals($expected, $list->toArray());
	}
开发者ID:redema,项目名称:sapphire,代码行数:31,代码来源:ArrayListTest.php

示例14: testSortSimpleDESCOrder

 public function testSortSimpleDESCOrder()
 {
     $list = new ArrayList(array(array('Name' => 'Steve'), (object) array('Name' => 'Bob'), array('Name' => 'John')));
     // Sort two arguments
     $list1 = $list->sort('Name', 'DESC');
     $this->assertEquals($list1->toArray(), array(array('Name' => 'Steve'), array('Name' => 'John'), (object) array('Name' => 'Bob')));
     // Sort single string
     $list2 = $list->sort('Name desc');
     $this->assertEquals($list2->toArray(), array(array('Name' => 'Steve'), array('Name' => 'John'), (object) array('Name' => 'Bob')));
     // Sort quoted string
     $list3 = $list->sort('"Name" DESCENDING');
     $this->assertEquals($list3->toArray(), array(array('Name' => 'Steve'), array('Name' => 'John'), (object) array('Name' => 'Bob')));
     // Sort array specifier
     $list4 = $list->sort(array('Name' => 'descending'));
     $this->assertEquals($list4->toArray(), array(array('Name' => 'Steve'), array('Name' => 'John'), (object) array('Name' => 'Bob')));
     // Check original list isn't altered
     $this->assertEquals($list->toArray(), array(array('Name' => 'Steve'), (object) array('Name' => 'Bob'), array('Name' => 'John')));
 }
开发者ID:maent45,项目名称:redefine_renos,代码行数:18,代码来源:ArrayListTest.php

示例15: handleAction

 function handleAction($request)
 {
     // This method can't be called without ajax.
     if (!$request->isAjax()) {
         $this->parentController->redirectBack();
         return;
     }
     // Protect against CSRF on destructive action
     if (!SecurityToken::inst()->checkRequest($request)) {
         return $this->httpError(400);
     }
     $actions = $this->batchActions();
     $actionClass = $actions[$request->param('BatchAction')]['class'];
     $actionHandler = new $actionClass();
     // Sanitise ID list and query the database for apges
     $ids = preg_split('/ *, */', trim($request->requestVar('csvIDs')));
     foreach ($ids as $k => $v) {
         if (!is_numeric($v)) {
             unset($ids[$k]);
         }
     }
     if ($ids) {
         if (class_exists('Translatable') && Object::has_extension('SiteTree', 'Translatable')) {
             Translatable::disable_locale_filter();
         }
         $pages = DataObject::get($this->recordClass, sprintf('"%s"."ID" IN (%s)', ClassInfo::baseDataClass($this->recordClass), implode(", ", $ids)));
         if (class_exists('Translatable') && Object::has_extension('SiteTree', 'Translatable')) {
             Translatable::enable_locale_filter();
         }
         if (Object::has_extension($this->recordClass, 'Versioned')) {
             // If we didn't query all the pages, then find the rest on the live site
             if (!$pages || $pages->Count() < sizeof($ids)) {
                 foreach ($ids as $id) {
                     $idsFromLive[$id] = true;
                 }
                 if ($pages) {
                     foreach ($pages as $page) {
                         unset($idsFromLive[$page->ID]);
                     }
                 }
                 $idsFromLive = array_keys($idsFromLive);
                 $sql = sprintf('"%s"."ID" IN (%s)', $this->recordClass, implode(", ", $idsFromLive));
                 $livePages = Versioned::get_by_stage($this->recordClass, 'Live', $sql);
                 if ($pages) {
                     // Can't merge into a DataList, need to condense into an actual list first
                     // (which will retrieve all records as objects, so its an expensive operation)
                     $pages = new ArrayList($pages->toArray());
                     $pages->merge($livePages);
                 } else {
                     $pages = $livePages;
                 }
             }
         }
     } else {
         $pages = new ArrayList();
     }
     return $actionHandler->run($pages);
 }
开发者ID:prostart,项目名称:cobblestonepath,代码行数:58,代码来源:CMSBatchActionHandler.php


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