Skip to content

Commit

Permalink
API Combine Sortable, Filterable and Limitable into SS_List
Browse files Browse the repository at this point in the history
  • Loading branch information
emteknetnz committed Oct 23, 2024
1 parent 715c2de commit e6fee3c
Show file tree
Hide file tree
Showing 26 changed files with 473 additions and 539 deletions.
11 changes: 4 additions & 7 deletions src/Forms/GridField/GridField.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -86,7 +83,7 @@ class GridField extends FormField
/**
* Data source.
*
* @var SS_List&Filterable&Sortable&Limitable
* @var SS_List
*/
protected $list = null;

Expand Down Expand Up @@ -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
*/
Expand All @@ -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()
{
Expand All @@ -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()
{
Expand Down
7 changes: 3 additions & 4 deletions src/Forms/GridField/GridFieldFilterHeader.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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();
Expand Down
3 changes: 1 addition & 2 deletions src/Forms/GridField/GridFieldLazyLoader.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;

/**
Expand All @@ -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 {
Expand Down
7 changes: 3 additions & 4 deletions src/Forms/GridField/GridFieldPaginator.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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;
}

Expand Down
7 changes: 3 additions & 4 deletions src/Forms/GridField/GridFieldSortableHeader.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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)
Expand Down
Loading

0 comments on commit e6fee3c

Please sign in to comment.