diff --git a/src/Forms/GridField/GridField.php b/src/Forms/GridField/GridField.php index 12b2522c087..a00aab521cf 100644 --- a/src/Forms/GridField/GridField.php +++ b/src/Forms/GridField/GridField.php @@ -22,9 +22,6 @@ use SilverStripe\ORM\DataList; use SilverStripe\ORM\DataObjectInterface; use SilverStripe\ORM\FieldType\DBField; -use SilverStripe\Model\List\Filterable; -use SilverStripe\Model\List\Limitable; -use SilverStripe\Model\List\Sortable; use SilverStripe\Model\List\SS_List; use SilverStripe\View\HTML; use SilverStripe\Model\ModelData; @@ -86,7 +83,7 @@ class GridField extends FormField /** * Data source. * - * @var SS_List&Filterable&Sortable&Limitable + * @var SS_List */ protected $list = null; @@ -397,7 +394,7 @@ public function getCastedValue($value, $castingDefinition) /** * Set the data source. * - * @param SS_List&Filterable&Sortable&Limitable $list + * @param SS_List $list * * @return $this */ @@ -411,7 +408,7 @@ public function setList(SS_List $list) /** * Get the data source. * - * @return SS_List&Filterable&Sortable&Limitable + * @return SS_List */ public function getList() { @@ -421,7 +418,7 @@ public function getList() /** * Get the data source after applying every {@link GridField_DataManipulator} to it. * - * @return SS_List&Filterable&Sortable&Limitable + * @return SS_List */ public function getManipulatedList() { diff --git a/src/Forms/GridField/GridFieldFilterHeader.php b/src/Forms/GridField/GridFieldFilterHeader.php index 7a9b0cbd658..eb8b84a4d50 100755 --- a/src/Forms/GridField/GridFieldFilterHeader.php +++ b/src/Forms/GridField/GridFieldFilterHeader.php @@ -11,7 +11,6 @@ use SilverStripe\Forms\FieldList; use SilverStripe\Forms\Form; use SilverStripe\Forms\Schema\FormSchema; -use SilverStripe\Model\List\Filterable; use SilverStripe\ORM\Search\SearchContext; use SilverStripe\Model\List\SS_List; use SilverStripe\Model\ArrayData; @@ -109,13 +108,13 @@ public function setSearchField(string $field): GridFieldFilterHeader */ protected function checkDataType($dataList) { - if ($dataList instanceof Filterable) { + if ($dataList instanceof SS_List) { return true; } else { // This will be changed to always throw an exception in a future major release. if ($this->throwExceptionOnBadDataType) { throw new LogicException( - static::class . " expects an SS_Filterable list to be passed to the GridField." + static::class . " expects an SS_List list to be passed to the GridField." ); } return false; @@ -209,7 +208,7 @@ public function getManipulatedData(GridField $gridField, SS_List $dataList) public function canFilterAnyColumns($gridField) { $list = $gridField->getList(); - if (!($list instanceof Filterable) || !$this->checkDataType($list)) { + if (!($list instanceof SS_List) || !$this->checkDataType($list)) { return false; } $modelClass = $gridField->getModelClass(); diff --git a/src/Forms/GridField/GridFieldLazyLoader.php b/src/Forms/GridField/GridFieldLazyLoader.php index 59844114e82..a6e97405e93 100755 --- a/src/Forms/GridField/GridFieldLazyLoader.php +++ b/src/Forms/GridField/GridFieldLazyLoader.php @@ -5,7 +5,6 @@ use SilverStripe\Forms\FormField; use SilverStripe\Forms\TabSet; use SilverStripe\Model\List\ArrayList; -use SilverStripe\Model\List\Filterable; use SilverStripe\Model\List\SS_List; /** @@ -28,7 +27,7 @@ public function getManipulatedData(GridField $gridField, SS_List $dataList) { // If we are lazy loading an empty the list if ($this->isLazy($gridField)) { - if ($dataList instanceof Filterable) { + if ($dataList instanceof SS_List) { // If our original list can be filtered, filter out all results. $dataList = $dataList->byIDs([-1]); } else { diff --git a/src/Forms/GridField/GridFieldPaginator.php b/src/Forms/GridField/GridFieldPaginator.php index fcda7a645e3..dd5b7497048 100755 --- a/src/Forms/GridField/GridFieldPaginator.php +++ b/src/Forms/GridField/GridFieldPaginator.php @@ -3,7 +3,6 @@ namespace SilverStripe\Forms\GridField; use SilverStripe\Core\Config\Configurable; -use SilverStripe\Model\List\Limitable; use SilverStripe\Model\List\SS_List; use SilverStripe\ORM\UnsavedRelationList; use SilverStripe\Model\ArrayData; @@ -89,13 +88,13 @@ public function getThrowExceptionOnBadDataType() */ protected function checkDataType($dataList) { - if ($dataList instanceof Limitable) { + if ($dataList instanceof SS_List) { return true; } else { // This will be changed to always throw an exception in a future major release. if ($this->throwExceptionOnBadDataType) { throw new LogicException( - static::class . " expects an SS_Limitable list to be passed to the GridField." + static::class . " expects an SS_List list to be passed to the GridField." ); } return false; @@ -183,7 +182,7 @@ public function getManipulatedData(GridField $gridField, SS_List $dataList) $startRow = 0; } - if (!($dataList instanceof Limitable) || ($dataList instanceof UnsavedRelationList)) { + if (!($dataList instanceof SS_List) || ($dataList instanceof UnsavedRelationList)) { return $dataList; } diff --git a/src/Forms/GridField/GridFieldSortableHeader.php b/src/Forms/GridField/GridFieldSortableHeader.php index b3705495ccc..fe09fb854a6 100644 --- a/src/Forms/GridField/GridFieldSortableHeader.php +++ b/src/Forms/GridField/GridFieldSortableHeader.php @@ -4,7 +4,6 @@ use SilverStripe\Forms\LiteralField; use SilverStripe\ORM\DataObjectSchema; -use SilverStripe\Model\List\Sortable; use SilverStripe\Model\List\ArrayList; use SilverStripe\Model\List\SS_List; use SilverStripe\ORM\DataObject; @@ -78,13 +77,13 @@ public function getThrowExceptionOnBadDataType() */ protected function checkDataType($dataList) { - if ($dataList instanceof Sortable) { + if ($dataList instanceof SS_List) { return true; } else { // This will be changed to always throw an exception in a future major release. if ($this->throwExceptionOnBadDataType) { throw new LogicException( - static::class . " expects an SS_Sortable list to be passed to the GridField." + static::class . " expects an SS_List list to be passed to the GridField." ); } return false; @@ -246,7 +245,7 @@ public function handleAction(GridField $gridField, $actionName, $arguments, $dat * {@link DataQuery} first. * * @param GridField $gridField - * @param SS_List&Sortable $dataList + * @param SS_List $dataList * @return SS_List */ public function getManipulatedData(GridField $gridField, SS_List $dataList) diff --git a/src/Model/List/ArrayList.php b/src/Model/List/ArrayList.php index 45f93456511..4071fda27d3 100644 --- a/src/Model/List/ArrayList.php +++ b/src/Model/List/ArrayList.php @@ -15,8 +15,8 @@ /** * A list object that wraps around an array of objects or arrays. * - * Note that (like DataLists), the implementations of the methods from SS_Filterable, SS_Sortable and - * SS_Limitable return a new instance of ArrayList, rather than modifying the existing instance. + * Note that (like DataLists), the implementations of the methods from SS_List return a new instance of ArrayList, + * rather than modifying the existing instance. * * For easy reference, methods that operate in this way are: * @@ -28,11 +28,8 @@ * * @template T * @implements SS_List - * @implements Filterable - * @implements Sortable - * @implements Limitable */ -class ArrayList extends ModelData implements SS_List, Filterable, Sortable, Limitable +class ArrayList extends ModelData implements SS_List { use SearchFilterable; @@ -597,7 +594,7 @@ public function find($key, $value) /** * Filter the list to include items with these characteristics * - * @see Filterable::filter() + * @see SS_List::filter() * @example $list->filter('Name', 'bob'); // only bob in the list * @example $list->filter('Name', array('aziz', 'bob'); // aziz and bob in list * @example $list->filter(array('Name'=>'bob, 'Age'=>21)); // bob with the Age 21 in list diff --git a/src/Model/List/Filterable.php b/src/Model/List/Filterable.php deleted file mode 100644 index 3ede8179faa..00000000000 --- a/src/Model/List/Filterable.php +++ /dev/null @@ -1,107 +0,0 @@ - - */ -interface Filterable extends SS_List -{ - - /** - * Returns TRUE if the list can be filtered by a given field expression. - * - * @param string $by - * @return bool - */ - public function canFilterBy($by); - - /** - * Return a new instance of this list that only includes items with these characteristics - * - * @example $list = $list->filter('Name', 'bob'); // only bob in the list - * @example $list = $list->filter('Name', array('aziz', 'bob'); // aziz and bob in list - * @example $list = $list->filter(array('Name'=>'bob, 'Age'=>21)); // bob with the age 21 - * @example $list = $list->filter(array('Name'=>'bob, 'Age'=>array(21, 43))); // bob with the Age 21 or 43 - * @example $list = $list->filter(array('Name'=>array('aziz','bob'), 'Age'=>array(21, 43))); - * // aziz with the age 21 or 43 and bob with the Age 21 or 43 - * - * @return static - */ - public function filter(); - - /** - * Return a copy of this list which contains items matching any of these characteristics. - * - * @example // only bob in the list - * $list = $list->filterAny('Name', 'bob'); - * // SQL: WHERE "Name" = 'bob' - * @example // azis or bob in the list - * $list = $list->filterAny('Name', array('aziz', 'bob'); - * // SQL: WHERE ("Name" IN ('aziz','bob')) - * @example // bob or anyone aged 21 in the list - * $list = $list->filterAny(array('Name'=>'bob, 'Age'=>21)); - * // SQL: WHERE ("Name" = 'bob' OR "Age" = '21') - * @example // bob or anyone aged 21 or 43 in the list - * $list = $list->filterAny(array('Name'=>'bob, 'Age'=>array(21, 43))); - * // SQL: WHERE ("Name" = 'bob' OR ("Age" IN ('21', '43')) - * @example // all bobs, phils or anyone aged 21 or 43 in the list - * $list = $list->filterAny(array('Name'=>array('bob','phil'), 'Age'=>array(21, 43))); - * // SQL: WHERE (("Name" IN ('bob', 'phil')) OR ("Age" IN ('21', '43')) - * - * @param string|array See {@link filter()} - * @return static - */ - public function filterAny(); - - /** - * Return a new instance of this list that excludes any items with these characteristics - * - * @example $list = $list->exclude('Name', 'bob'); // exclude bob from list - * @example $list = $list->exclude('Name', array('aziz', 'bob'); // exclude aziz and bob from list - * @example $list = $list->exclude(array('Name'=>'bob, 'Age'=>21)); // exclude bob that has Age 21 - * @example $list = $list->exclude(array('Name'=>'bob, 'Age'=>array(21, 43))); // exclude bob with Age 21 or 43 - * @example $list = $list->exclude(array('Name'=>array('bob','phil'), 'Age'=>array(21, 43))); - * // bob age 21 or 43, phil age 21 or 43 would be excluded - * - * @return static - */ - public function exclude(); - - /** - * Return a new instance of this list that excludes any items with these characteristics - * Filter this List by a callback function. The function will be passed each record of the List in turn, - * and must return true for the record to be included. Returns the filtered list. - * - * @example $list = $list->filterByCallback(function($item, $list) { return $item->Age == 9; }) - * @param callable $callback - * @return SS_List - */ - public function filterByCallback($callback); - - /** - * Return the first item with the given ID - * - * @param int $id - * @return T|null - */ - public function byID($id); - - /** - * Filter this list to only contain the given Primary IDs - * - * @param array $ids Array of integers - * @return static - */ - public function byIDs($ids); -} diff --git a/src/Model/List/Limitable.php b/src/Model/List/Limitable.php deleted file mode 100644 index 27a2fe8bee7..00000000000 --- a/src/Model/List/Limitable.php +++ /dev/null @@ -1,32 +0,0 @@ - - */ -interface Limitable extends SS_List -{ - - /** - * Returns a new instance of this list where no more than $limit records are included. - * If $offset is specified, then that many records at the beginning of the list will be skipped. - * This matches the behaviour of the SQL LIMIT clause. - * - * If `$length` is null, then no limit is applied. If `$length` is 0, then an empty list is returned. - * - * @throws InvalidArgumentException if $length or offset are negative - * @return static - */ - public function limit(?int $length, int $offset = 0): Limitable; -} diff --git a/src/Model/List/ListDecorator.php b/src/Model/List/ListDecorator.php index 6cfc963b425..ed42823b386 100644 --- a/src/Model/List/ListDecorator.php +++ b/src/Model/List/ListDecorator.php @@ -11,14 +11,11 @@ * functionality. It passes through list methods to the underlying list * implementation. * - * @template TList of SS_List&Sortable&Filterable&Limitable + * @template TList of SS_List * @template T * @implements SS_List - * @implements Sortable - * @implements Filterable - * @implements Limitable */ -abstract class ListDecorator extends ModelData implements SS_List, Sortable, Filterable, Limitable +abstract class ListDecorator extends ModelData implements SS_List { /** * @var TList @@ -28,7 +25,7 @@ abstract class ListDecorator extends ModelData implements SS_List, Sortable, Fil /** * @param TList $list */ - public function __construct(SS_List&Sortable&Filterable&Limitable $list) + public function __construct(SS_List $list) { $this->setList($list); parent::__construct(); @@ -37,7 +34,7 @@ public function __construct(SS_List&Sortable&Filterable&Limitable $list) /** * @return TList */ - public function getList(): SS_List&Sortable&Filterable&Limitable + public function getList(): SS_List { return $this->list; } @@ -53,7 +50,7 @@ public function getList(): SS_List&Sortable&Filterable&Limitable * @param TListA $list * @return static */ - public function setList(SS_List&Sortable&Filterable&Limitable $list): ListDecorator + public function setList(SS_List $list): ListDecorator { $this->list = $list; $this->failover = $this->list; @@ -249,7 +246,7 @@ public function filterAny() /** * Note that, in the current implementation, the filtered list will be an ArrayList, but this may change in a * future implementation. - * @see Filterable::filterByCallback() + * @see SS_List::filterByCallback() * * @example $list = $list->filterByCallback(function($item, $list) { return $item->Age == 9; }) * @param callable $callback @@ -275,7 +272,7 @@ public function filterByCallback($callback) /** * @return TList */ - public function limit(?int $length, int $offset = 0): SS_List&Sortable&Filterable&Limitable + public function limit(?int $length, int $offset = 0): SS_List { return $this->list->limit($length, $offset); } diff --git a/src/Model/List/SS_List.php b/src/Model/List/SS_List.php index 3b788193f5d..75b023c553e 100644 --- a/src/Model/List/SS_List.php +++ b/src/Model/List/SS_List.php @@ -15,7 +15,6 @@ */ interface SS_List extends ArrayAccess, Countable, IteratorAggregate { - /** * Returns all the items in the list in an array. * @@ -94,4 +93,135 @@ public function column($colName = "ID"); * @return static */ public function each($callback); + + + /** + * Returns TRUE if the list can be filtered by a given field expression. + * + * @param string $by + * @return bool + */ + public function canFilterBy($by); + + /** + * Return a new instance of this list that only includes items with these characteristics + * + * @example $list = $list->filter('Name', 'bob'); // only bob in the list + * @example $list = $list->filter('Name', array('aziz', 'bob'); // aziz and bob in list + * @example $list = $list->filter(array('Name'=>'bob, 'Age'=>21)); // bob with the age 21 + * @example $list = $list->filter(array('Name'=>'bob, 'Age'=>array(21, 43))); // bob with the Age 21 or 43 + * @example $list = $list->filter(array('Name'=>array('aziz','bob'), 'Age'=>array(21, 43))); + * // aziz with the age 21 or 43 and bob with the Age 21 or 43 + * + * @return static + */ + public function filter(); + + /** + * Return a copy of this list which contains items matching any of these characteristics. + * + * @example // only bob in the list + * $list = $list->filterAny('Name', 'bob'); + * // SQL: WHERE "Name" = 'bob' + * @example // azis or bob in the list + * $list = $list->filterAny('Name', array('aziz', 'bob'); + * // SQL: WHERE ("Name" IN ('aziz','bob')) + * @example // bob or anyone aged 21 in the list + * $list = $list->filterAny(array('Name'=>'bob, 'Age'=>21)); + * // SQL: WHERE ("Name" = 'bob' OR "Age" = '21') + * @example // bob or anyone aged 21 or 43 in the list + * $list = $list->filterAny(array('Name'=>'bob, 'Age'=>array(21, 43))); + * // SQL: WHERE ("Name" = 'bob' OR ("Age" IN ('21', '43')) + * @example // all bobs, phils or anyone aged 21 or 43 in the list + * $list = $list->filterAny(array('Name'=>array('bob','phil'), 'Age'=>array(21, 43))); + * // SQL: WHERE (("Name" IN ('bob', 'phil')) OR ("Age" IN ('21', '43')) + * + * @param string|array See {@link filter()} + * @return static + */ + public function filterAny(); + + /** + * Return a new instance of this list that excludes any items with these characteristics + * + * @example $list = $list->exclude('Name', 'bob'); // exclude bob from list + * @example $list = $list->exclude('Name', array('aziz', 'bob'); // exclude aziz and bob from list + * @example $list = $list->exclude(array('Name'=>'bob, 'Age'=>21)); // exclude bob that has Age 21 + * @example $list = $list->exclude(array('Name'=>'bob, 'Age'=>array(21, 43))); // exclude bob with Age 21 or 43 + * @example $list = $list->exclude(array('Name'=>array('bob','phil'), 'Age'=>array(21, 43))); + * // bob age 21 or 43, phil age 21 or 43 would be excluded + * + * @return static + */ + public function exclude(); + + /** + * Return a new instance of this list that excludes any items with these characteristics + * Filter this List by a callback function. The function will be passed each record of the List in turn, + * and must return true for the record to be included. Returns the filtered list. + * + * @example $list = $list->filterByCallback(function($item, $list) { return $item->Age == 9; }) + * @param callable $callback + * @return SS_List + */ + public function filterByCallback($callback); + + /** + * Return the first item with the given ID + * + * @param int $id + * @return T|null + */ + public function byID($id); + + /** + * Filter this list to only contain the given Primary IDs + * + * @param array $ids Array of integers + * @return static + */ + public function byIDs($ids); + + /** + * Returns TRUE if the list can be sorted by a field. + * + * @param string $by + * @return bool + */ + public function canSortBy($by); + + /** + * Return a new instance of this list that is sorted by one or more fields. You can either pass in a single + * field name and direction, or a map of field names to sort directions. + * + * @example $list = $list->sort('Name'); // default ASC sorting + * @example $list = $list->sort('Name DESC'); // DESC sorting + * @example $list = $list->sort('Name', 'ASC'); + * @example $list = $list->sort(array('Name'=>'ASC,'Age'=>'DESC')); + * + * @return static + */ + public function sort(); + + + /** + * Return a new instance of this list based on reversing the current sort. + * + * @example $list = $list->reverse(); + * + * @return static + */ + public function reverse(); + + /** + * Returns a new instance of this list where no more than $limit records are included. + * If $offset is specified, then that many records at the beginning of the list will be skipped. + * This matches the behaviour of the SQL LIMIT clause. + * + * If `$length` is null, then no limit is applied. If `$length` is 0, then an empty list is returned. + * + * @throws InvalidArgumentException if $length or offset are negative + * @return static + */ + public function limit(?int $length, int $offset = 0): Limitable; } diff --git a/src/Model/List/Sortable.php b/src/Model/List/Sortable.php deleted file mode 100644 index c818cc5644e..00000000000 --- a/src/Model/List/Sortable.php +++ /dev/null @@ -1,51 +0,0 @@ - - */ -interface Sortable extends SS_List -{ - - /** - * Returns TRUE if the list can be sorted by a field. - * - * @param string $by - * @return bool - */ - public function canSortBy($by); - - /** - * Return a new instance of this list that is sorted by one or more fields. You can either pass in a single - * field name and direction, or a map of field names to sort directions. - * - * @example $list = $list->sort('Name'); // default ASC sorting - * @example $list = $list->sort('Name DESC'); // DESC sorting - * @example $list = $list->sort('Name', 'ASC'); - * @example $list = $list->sort(array('Name'=>'ASC,'Age'=>'DESC')); - * - * @return static - */ - public function sort(); - - - /** - * Return a new instance of this list based on reversing the current sort. - * - * @example $list = $list->reverse(); - * - * @return static - */ - public function reverse(); -} diff --git a/src/ORM/DataList.php b/src/ORM/DataList.php index a65f5b161ef..04614886784 100644 --- a/src/ORM/DataList.php +++ b/src/ORM/DataList.php @@ -14,10 +14,7 @@ use Traversable; use SilverStripe\ORM\DataQuery; use SilverStripe\Model\List\ArrayList; -use SilverStripe\Model\List\Filterable; -use SilverStripe\Model\List\Limitable; use SilverStripe\Model\List\Map; -use SilverStripe\Model\List\Sortable; use SilverStripe\Model\List\SS_List; use SilverStripe\ORM\Filters\SearchFilterable; @@ -43,11 +40,8 @@ * * @template T of DataObject * @implements SS_List - * @implements Filterable - * @implements Sortable - * @implements Limitable */ -class DataList extends ModelData implements SS_List, Filterable, Sortable, Limitable +class DataList extends ModelData implements SS_List { use SearchFilterable; @@ -474,7 +468,7 @@ public function orderBy(string $orderBy): static * * Raw SQL is not accepted, only actual field names can be passed * - * @see Filterable::filter() + * @see SS_List::filter() * * @example $list = $list->filter('Name', 'bob'); // only bob in the list * @example $list = $list->filter('Name', array('aziz', 'bob'); // aziz and bob in list @@ -591,7 +585,7 @@ private function getFilterAnySubquery(DataQuery $query, array $whereArguments): /** * Note that, in the current implementation, the filtered list will be an ArrayList, but this may change in a * future implementation. - * @see Filterable::filterByCallback() + * @see SS_List::filterByCallback() * * @example $list = $list->filterByCallback(function($item, $list) { return $item->Age == 9; }) * @param callable $callback diff --git a/src/ORM/EagerLoadedList.php b/src/ORM/EagerLoadedList.php index d65a49d3767..c011167dedb 100644 --- a/src/ORM/EagerLoadedList.php +++ b/src/ORM/EagerLoadedList.php @@ -11,10 +11,7 @@ use LogicException; use SilverStripe\Core\ArrayLib; use SilverStripe\Model\List\ArrayList; -use SilverStripe\Model\List\Filterable; -use SilverStripe\Model\List\Limitable; use SilverStripe\Model\List\Map; -use SilverStripe\Model\List\Sortable; use SilverStripe\Model\List\SS_List; use SilverStripe\ORM\Filters\SearchFilterable; use Traversable; @@ -32,11 +29,8 @@ * @template T of DataObject * @implements Relation * @implements SS_List - * @implements Filterable - * @implements Sortable - * @implements Limitable */ -class EagerLoadedList extends ModelData implements Relation, SS_List, Filterable, Sortable, Limitable +class EagerLoadedList extends ModelData implements Relation, SS_List { use SearchFilterable; diff --git a/src/ORM/Relation.php b/src/ORM/Relation.php index 62b2b266cb2..0bc0d3b02fc 100644 --- a/src/ORM/Relation.php +++ b/src/ORM/Relation.php @@ -2,9 +2,6 @@ namespace SilverStripe\ORM; -use SilverStripe\Model\List\Filterable; -use SilverStripe\Model\List\Limitable; -use SilverStripe\Model\List\Sortable; use SilverStripe\Model\List\SS_List; use SilverStripe\ORM\FieldType\DBField; @@ -19,11 +16,8 @@ * * @template T * @extends SS_List - * @extends Filterable - * @extends Sortable - * @extends Limitable */ -interface Relation extends SS_List, Filterable, Sortable, Limitable +interface Relation extends SS_List { /** diff --git a/src/ORM/Search/BasicSearchContext.php b/src/ORM/Search/BasicSearchContext.php index c7b10685810..5f33be22efd 100644 --- a/src/ORM/Search/BasicSearchContext.php +++ b/src/ORM/Search/BasicSearchContext.php @@ -8,11 +8,9 @@ use SilverStripe\Core\Config\Configurable; use SilverStripe\Core\Injector\Injector; use SilverStripe\Dev\Deprecation; -use SilverStripe\Model\List\Filterable; use SilverStripe\ORM\Filters\PartialMatchFilter; use SilverStripe\ORM\Filters\SearchFilter; -use SilverStripe\Model\List\Limitable; -use SilverStripe\Model\List\Sortable; +use SilverStripe\Model\List\SS_List; /** * A SearchContext that can be used with non-ORM data. @@ -37,12 +35,12 @@ class BasicSearchContext extends SearchContext * for example "Comments__Name" instead of the filter name "Comments.Name". * @param array|bool|string $sort Field to sort on. * @param array|null|string $limit - * @param Filterable&Sortable&Limitable $existingQuery + * @param SS_List $existingQuery */ - public function getQuery($searchParams, $sort = false, $limit = false, $existingQuery = null): Filterable&Sortable&Limitable + public function getQuery($searchParams, $sort = false, $limit = false, $existingQuery = null): SS_List { - if (!$existingQuery || !($existingQuery instanceof Filterable) || !($existingQuery instanceof Sortable) || !($existingQuery instanceof Limitable)) { - throw new InvalidArgumentException('getQuery requires a pre-existing filterable/sortable/limitable list to be passed as $existingQuery.'); + if (!$existingQuery || !is_a($existingQuery, SS_List::class)) { + throw new InvalidArgumentException('getQuery requires a pre-existing SS_List list to be passed as $existingQuery.'); } if ((count(func_get_args()) >= 3) && (!in_array(gettype($limit), ['array', 'NULL', 'string']))) { @@ -98,7 +96,7 @@ private function applySearchFilters(array $searchParams): array return $applied; } - private function applyGeneralSearchField(array &$searchParams, Filterable $existingQuery): Filterable + private function applyGeneralSearchField(array &$searchParams, SS_List $existingQuery): SS_List { $generalFieldName = static::config()->get('general_search_field_name'); if (array_key_exists($generalFieldName, $searchParams)) { diff --git a/tests/php/Model/List/ArrayListTest.php b/tests/php/Model/List/ArrayListTest.php index 6aca22cf737..078292bc18c 100644 --- a/tests/php/Model/List/ArrayListTest.php +++ b/tests/php/Model/List/ArrayListTest.php @@ -5,7 +5,7 @@ use SilverStripe\Dev\SapphireTest; use SilverStripe\Model\List\ArrayList; use SilverStripe\ORM\DataObject; -use SilverStripe\Model\List\Filterable; +use SilverStripe\Model\List\SS_List; use SilverStripe\Model\ArrayData; use SilverStripe\Model\List\Map; use stdClass; @@ -1455,7 +1455,7 @@ function ($item, $list) { $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 Filterable, 'The List should be of type SS_Filterable'); + $this->assertTrue($list instanceof SS_List, 'The List should be of type SS_Filterable'); } /** diff --git a/tests/php/ORM/DataListTest.php b/tests/php/ORM/DataListTest.php index bb67daa199e..d5618aa0163 100755 --- a/tests/php/ORM/DataListTest.php +++ b/tests/php/ORM/DataListTest.php @@ -12,7 +12,7 @@ use SilverStripe\ORM\DataList; use SilverStripe\ORM\DataQuery; use SilverStripe\ORM\DB; -use SilverStripe\Model\List\Filterable; +use SilverStripe\Model\List\SS_List; use SilverStripe\ORM\Filters\ExactMatchFilter; use SilverStripe\ORM\Tests\DataObjectTest\DataListQueryCounter; use SilverStripe\ORM\Tests\DataObjectTest\Fixture; @@ -1591,7 +1591,7 @@ function ($item, $list) use ($team1ID) { $this->assertEquals(2, $list->count()); $this->assertEquals($expected, $result, 'List should only contain comments from Team 1 (Joe and Bob)'); - $this->assertTrue($list instanceof Filterable, 'The List should be of type SS_Filterable'); + $this->assertTrue($list instanceof SS_List, 'The List should be of type SS_List'); } /** diff --git a/tests/php/ORM/EagerLoadedListTest.php b/tests/php/ORM/EagerLoadedListTest.php index 3eca2f184ee..ac24e645664 100644 --- a/tests/php/ORM/EagerLoadedListTest.php +++ b/tests/php/ORM/EagerLoadedListTest.php @@ -10,7 +10,7 @@ use SilverStripe\ORM\Connect\MySQLiConnector; use SilverStripe\ORM\EagerLoadedList; use SilverStripe\ORM\DB; -use SilverStripe\Model\List\Filterable; +use SilverStripe\Model\List\SS_List; use SilverStripe\ORM\Tests\DataObjectTest\EquipmentCompany; use SilverStripe\ORM\Tests\DataObjectTest\Fan; use SilverStripe\ORM\Tests\DataObjectTest\Player; @@ -1690,7 +1690,7 @@ function ($item, $list) use ($team1ID) { $this->assertEquals(2, $list->count()); $this->assertEquals($expected, $result, 'List should only contain comments from Team 1 (Joe and Bob)'); - $this->assertTrue($list instanceof Filterable, 'The List should be of type SS_Filterable'); + $this->assertTrue($list instanceof SS_List, 'The List should be of type SS_List'); } public function testSimpleExclude()