Skip to content

Commit

Permalink
Merge pull request #420 from creative-commoners/pulls/5/ss-list-combine
Browse files Browse the repository at this point in the history
API Check is instance of SS_List
  • Loading branch information
GuySartorelli authored Oct 30, 2024
2 parents 718cc13 + b4031bc commit 12d355b
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 7 deletions.
3 changes: 1 addition & 2 deletions src/GridFieldConfigurablePaginator.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
use SilverStripe\Forms\GridField\GridFieldPaginator;
use SilverStripe\Forms\GridField\GridState_Data;
use SilverStripe\Model\List\ArrayList;
use SilverStripe\Model\List\Limitable;
use SilverStripe\Model\List\SS_List;
use SilverStripe\ORM\UnsavedRelationList;
use SilverStripe\Model\ArrayData;
Expand Down Expand Up @@ -256,7 +255,7 @@ public function getManipulatedData(GridField $gridField, SS_List $dataList)
$this->setItemsPerPage($state->pageSize);
}

if (!($dataList instanceof Limitable) || ($dataList instanceof UnsavedRelationList)) {
if (!($dataList instanceof SS_List) || ($dataList instanceof UnsavedRelationList)) {
return $dataList;
}

Expand Down
9 changes: 4 additions & 5 deletions src/GridFieldNestedForm.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
use SilverStripe\ORM\DataList;
use SilverStripe\ORM\DataObject;
use SilverStripe\ORM\DataObjectInterface;
use SilverStripe\Model\List\Filterable;
use SilverStripe\ORM\Hierarchy\Hierarchy;
use SilverStripe\Model\List\SS_List;
use SilverStripe\Versioned\Versioned;
Expand Down Expand Up @@ -362,7 +361,7 @@ public function handleNestedItem(
throw new Exception('Max nesting level reached');
}
$list = $gridField->getList();
if (!$record && $request && $list instanceof Filterable) {
if (!$record && $request && $list instanceof SS_List) {
$recordID = $request->param('RecordID');
$record = $list->byID($recordID);
}
Expand Down Expand Up @@ -411,7 +410,7 @@ public function toggleNestedItem(
ModelData|null $record = null
) {
$list = $gridField->getList();
if (!$record && $request && $list instanceof Filterable) {
if (!$record && $request && $list instanceof SS_List) {
$recordID = $request->param('RecordID');
$record = $list->byID($recordID);
}
Expand Down Expand Up @@ -460,7 +459,7 @@ public function handleSave(GridField $gridField, DataObjectInterface $record)
}
foreach ($request->postVars() as $key => $val) {
$list = $gridField->getList();
if ($list instanceof Filterable
if ($list instanceof SS_List
&& preg_match("/{$gridField->getName()}-{$postKey}-(\d+)/", $key, $matches)
) {
$recordID = $matches[1];
Expand All @@ -482,7 +481,7 @@ public function getManipulatedData(GridField $gridField, SS_List $dataList)
&& is_a($gridField->getModelClass(), DataObject::class, true)
&& DataObject::has_extension($gridField->getModelClass(), Hierarchy::class)
&& $gridField->getForm()->getController() instanceof ModelAdmin
&& $dataList instanceof Filterable
&& $dataList instanceof SS_List
) {
$dataList = $dataList->filter('ParentID', 0);
}
Expand Down

0 comments on commit 12d355b

Please sign in to comment.