本文整理匯總了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());
}