mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-10-22 14:05:37 +02:00
Compare commits
2 Commits
595656636c
...
0225c563e1
Author | SHA1 | Date | |
---|---|---|---|
|
0225c563e1 | ||
|
41cbfe4e49 |
@ -851,7 +851,7 @@ class ArrayList extends ModelData implements SS_List
|
||||
}
|
||||
|
||||
/**
|
||||
* @see Filterable::filterByCallback()
|
||||
* @see SS_List::filterByCallback()
|
||||
*
|
||||
* @example $list = $list->filterByCallback(function($item, $list) { return $item->Age == 9; })
|
||||
* @param callable $callback
|
||||
@ -861,7 +861,7 @@ class ArrayList extends ModelData implements SS_List
|
||||
{
|
||||
if (!is_callable($callback)) {
|
||||
throw new LogicException(sprintf(
|
||||
"SS_Filterable::filterByCallback() passed callback must be callable, '%s' given",
|
||||
"SS_List::filterByCallback() passed callback must be callable, '%s' given",
|
||||
gettype($callback)
|
||||
));
|
||||
}
|
||||
|
@ -11,19 +11,18 @@ use Traversable;
|
||||
* functionality. It passes through list methods to the underlying list
|
||||
* implementation.
|
||||
*
|
||||
* @template TList of SS_List
|
||||
* @template T
|
||||
* @implements SS_List<T>
|
||||
*/
|
||||
abstract class ListDecorator extends ModelData implements SS_List
|
||||
{
|
||||
/**
|
||||
* @var TList<T>
|
||||
* @var SS_List<T>
|
||||
*/
|
||||
protected SS_List&Sortable&Filterable&Limitable $list;
|
||||
protected SS_List $list;
|
||||
|
||||
/**
|
||||
* @param TList<T> $list
|
||||
* @param SS_List<T> $list
|
||||
*/
|
||||
public function __construct(SS_List $list)
|
||||
{
|
||||
@ -32,7 +31,7 @@ abstract class ListDecorator extends ModelData implements SS_List
|
||||
}
|
||||
|
||||
/**
|
||||
* @return TList<T>
|
||||
* @return SS_List<T>
|
||||
*/
|
||||
public function getList(): SS_List
|
||||
{
|
||||
@ -45,10 +44,10 @@ abstract class ListDecorator extends ModelData implements SS_List
|
||||
* Useful for keeping a decorator/paginated list configuration intact while modifying
|
||||
* the underlying list.
|
||||
*
|
||||
* @template TListA
|
||||
* @template SS_ListA
|
||||
* @template TA
|
||||
* @param TListA<TA> $list
|
||||
* @return static<TListA, TA>
|
||||
* @param SS_ListA<TA> $list
|
||||
* @return static<SS_ListA, TA>
|
||||
*/
|
||||
public function setList(SS_List $list): ListDecorator
|
||||
{
|
||||
@ -162,7 +161,7 @@ abstract class ListDecorator extends ModelData implements SS_List
|
||||
}
|
||||
|
||||
/**
|
||||
* @return TList<T>
|
||||
* @return SS_List<T>
|
||||
*/
|
||||
public function each($callback)
|
||||
{
|
||||
@ -188,7 +187,7 @@ abstract class ListDecorator extends ModelData implements SS_List
|
||||
* @example $list->sort('Name', 'ASC');
|
||||
* @example $list->sort(array('Name'=>'ASC,'Age'=>'DESC'));
|
||||
*
|
||||
* @return TList<T>
|
||||
* @return SS_List<T>
|
||||
*/
|
||||
public function sort()
|
||||
{
|
||||
@ -208,7 +207,7 @@ abstract class ListDecorator extends ModelData implements SS_List
|
||||
* @example $list->filter(array('Name'=>'bob, 'Age'=>21)); // bob or someone with Age 21
|
||||
* @example $list->filter(array('Name'=>'bob, 'Age'=>array(21, 43))); // bob or anyone with Age 21 or 43
|
||||
*
|
||||
* @return TList<T>
|
||||
* @return SS_List<T>
|
||||
*/
|
||||
public function filter()
|
||||
{
|
||||
@ -236,7 +235,7 @@ abstract class ListDecorator extends ModelData implements SS_List
|
||||
*
|
||||
* @param string|array See {@link filter()}
|
||||
*
|
||||
* @return TList<T>
|
||||
* @return SS_List<T>
|
||||
*/
|
||||
public function filterAny()
|
||||
{
|
||||
@ -256,7 +255,7 @@ abstract class ListDecorator extends ModelData implements SS_List
|
||||
{
|
||||
if (!is_callable($callback)) {
|
||||
throw new LogicException(sprintf(
|
||||
"SS_Filterable::filterByCallback() passed callback must be callable, '%s' given",
|
||||
"SS_List::filterByCallback() passed callback must be callable, '%s' given",
|
||||
gettype($callback)
|
||||
));
|
||||
}
|
||||
@ -270,7 +269,7 @@ abstract class ListDecorator extends ModelData implements SS_List
|
||||
}
|
||||
|
||||
/**
|
||||
* @return TList<T>
|
||||
* @return SS_List<T>
|
||||
*/
|
||||
public function limit(?int $length, int $offset = 0): SS_List
|
||||
{
|
||||
@ -287,7 +286,7 @@ abstract class ListDecorator extends ModelData implements SS_List
|
||||
*
|
||||
* @param array $ids Array of integers
|
||||
*
|
||||
* @return TList<T>
|
||||
* @return SS_List<T>
|
||||
*/
|
||||
public function byIDs($ids)
|
||||
{
|
||||
@ -302,7 +301,7 @@ abstract class ListDecorator extends ModelData implements SS_List
|
||||
* @example $list->exclude(array('Name'=>'bob, 'Age'=>21)); // exclude bob or someone with Age 21
|
||||
* @example $list->exclude(array('Name'=>'bob, 'Age'=>array(21, 43))); // exclude bob or anyone with Age 21 or 43
|
||||
*
|
||||
* @return TList<T>
|
||||
* @return SS_List<T>
|
||||
*/
|
||||
public function exclude()
|
||||
{
|
||||
|
@ -15,6 +15,11 @@ use IteratorAggregate;
|
||||
*/
|
||||
interface SS_List extends ArrayAccess, Countable, IteratorAggregate
|
||||
{
|
||||
/**
|
||||
* Representation of the list for use in a template
|
||||
*/
|
||||
public function forTemplate(): string;
|
||||
|
||||
/**
|
||||
* Returns all the items in the list in an array.
|
||||
*
|
||||
|
@ -595,7 +595,7 @@ class DataList extends ModelData implements SS_List
|
||||
{
|
||||
if (!is_callable($callback)) {
|
||||
throw new LogicException(sprintf(
|
||||
"SS_Filterable::filterByCallback() passed callback must be callable, '%s' given",
|
||||
"SS_List::filterByCallback() passed callback must be callable, '%s' given",
|
||||
gettype($callback)
|
||||
));
|
||||
}
|
||||
|
@ -1455,7 +1455,7 @@ class ArrayListTest extends SapphireTest
|
||||
$this->assertEquals(2, $list->count());
|
||||
$this->assertEquals($steve, $list[0]->toMap(), 'List should only contain Steve and Clair');
|
||||
$this->assertEquals($clair, $list[1]->toMap(), 'List should only contain Steve and Clair');
|
||||
$this->assertTrue($list instanceof SS_List, 'The List should be of type SS_Filterable');
|
||||
$this->assertTrue($list instanceof SS_List, 'The List should be of type SS_List');
|
||||
}
|
||||
|
||||
/**
|
||||
|
Loading…
Reference in New Issue
Block a user