本文整理汇总了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;
}
示例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);
}
示例3: get
/**
* @return \Heyday\Redirects\Redirect[]
*/
public function get()
{
return array_map([$this->transformer, 'transform'], $this->list->toArray());
}