当前位置: 首页>>代码示例>>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;未经允许,请勿转载。