當前位置: 首頁>>代碼示例>>PHP>>正文


PHP DataList::toArray方法代碼示例

本文整理匯總了PHP中DataList::toArray方法的典型用法代碼示例。如果您正苦於以下問題:PHP DataList::toArray方法的具體用法?PHP DataList::toArray怎麽用?PHP DataList::toArray使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在DataList的用法示例。


在下文中一共展示了DataList::toArray方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: get

 /**
  * In order to improve performance for a larger number of redirects, instead of a standard array being generated
  *      an associative array (keyed on the 'from' URL) is generated which allows a direct check rather than needing
  *      to iterate through a large list (especially considering this would be done on each page request).
  *
  * @return \Heyday\Redirects\Redirect[]
  */
 public function get()
 {
     $data = array();
     /* @var \Heyday\Redirects\Redirect $redirect */
     foreach (array_map([$this->transformer, 'transform'], $this->list->toArray()) as $redirect) {
         // Format the URL so it will match the SS_HTTPRequest request URL
         $data[Redirect::formatUrl($redirect->getFrom())] = $redirect;
     }
     return $data;
 }
開發者ID:heyday,項目名稱:silverstripe-redirects,代碼行數:17,代碼來源:DataListDataSource.php

示例2: sortByRating

 /**
  * takes a DataList of Rateable DataObjects and sorts them by their average score 
  * @param DataList $list
  * @return ArrayList
  **/
 public function sortByRating(DataList $list, $dir = 'DESC')
 {
     $items = new ArrayList($list->toArray());
     foreach ($items as $item) {
         $score = $item->getAverageScore();
         $item->Score = $score ? $score : 0;
         $item->Title = $item->Title;
     }
     return $items->sort('Score', $dir);
 }
開發者ID:helpfulrobot,項目名稱:sheadawson-silverstripe-rateable,代碼行數:15,代碼來源:RateableService.php

示例3: get

 /**
  * @return \Heyday\Redirects\Redirect[]
  */
 public function get()
 {
     return array_map([$this->transformer, 'transform'], $this->list->toArray());
 }
開發者ID:helpfulrobot,項目名稱:heyday-silverstripe-redirects,代碼行數:7,代碼來源:DataListDataSource.php


注:本文中的DataList::toArray方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。