Skip to content

Commit

Permalink
API Update code to reflect changes in silverstripe/admin
Browse files Browse the repository at this point in the history
  • Loading branch information
GuySartorelli committed Oct 25, 2024
1 parent f7b0f01 commit efdaa8e
Showing 1 changed file with 11 additions and 11 deletions.
22 changes: 11 additions & 11 deletions code/Controllers/CMSMain.php
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ class CMSMain extends LeftAndMain implements CurrentPageIdentifier, PermissionPr

private static $menu_priority = 10;

private static $tree_class = SiteTree::class;
private static $model_class = SiteTree::class;

private static $session_namespace = CMSMain::class;

Expand Down Expand Up @@ -502,7 +502,7 @@ public function LinkPreview()
*/
public function SiteTreeAsUL()
{
$treeClass = $this->config()->get('tree_class');
$treeClass = $this->config()->get('model_class');
$filter = $this->getSearchFilter();

DataObject::singleton($treeClass)->prepopulateTreeDataCache(null, [
Expand Down Expand Up @@ -655,7 +655,7 @@ public function getTreeNodeClasses(SiteTree $node)
public function getsubtree(HTTPRequest $request): HTTPResponse
{
$html = $this->getSiteTreeFor(
$this->config()->get('tree_class'),
$this->config()->get('model_class'),
$request->getVar('ID'),
null,
null,
Expand Down Expand Up @@ -700,7 +700,7 @@ public function updatetreenodes(HTTPRequest $request): HTTPResponse
// Find the next & previous nodes, for proper positioning (Sort isn't good enough - it's not a raw offset)
$prev = null;

$className = $this->config()->get('tree_class');
$className = $this->config()->get('model_class');
$next = DataObject::get($className)
->filter('ParentID', $record->ParentID)
->filter('Sort:GreaterThan', $record->Sort)
Expand Down Expand Up @@ -760,7 +760,7 @@ public function savetreenode(HTTPRequest $request): HTTPResponse
);
}

$className = $this->config()->get('tree_class');
$className = $this->config()->get('model_class');
$id = $request->requestVar('ID');
$parentID = $request->requestVar('ParentID');
if (!is_numeric($id) || !is_numeric($parentID)) {
Expand Down Expand Up @@ -1250,7 +1250,7 @@ public function getRecord($id, $versionID = null)
if (!$id) {
return null;
}
$treeClass = $this->config()->get('tree_class');
$treeClass = $this->config()->get('model_class');
if ($id instanceof $treeClass) {
return $id;
}
Expand Down Expand Up @@ -1637,7 +1637,7 @@ public function getList($params = [], $parentID = 0)
if ($filter = $this->getQueryFilter($params)) {
return $filter->getFilteredPages();
} else {
$list = DataList::create($this->config()->get('tree_class'));
$list = DataList::create($this->config()->get('model_class'));
$parentID = is_numeric($parentID) ? $parentID : 0;
return $list->filter("ParentID", $parentID);
}
Expand Down Expand Up @@ -1767,7 +1767,7 @@ public function currentPageID()
*/
public function save(array $data, Form $form): HTTPResponse
{
$className = $this->config()->get('tree_class');
$className = $this->config()->get('model_class');

// Existing or new record?
$id = $data['ID'];
Expand Down Expand Up @@ -1840,7 +1840,7 @@ public function save(array $data, Form $form): HTTPResponse
*/
public function getNewItem($id, $setID = true)
{
$parentClass = $this->config()->get('tree_class');
$parentClass = $this->config()->get('model_class');
list(, $className, $parentID) = array_pad(explode('-', $id ?? ''), 3, null);

if (!is_a($className, $parentClass ?? '', true)) {
Expand Down Expand Up @@ -2024,7 +2024,7 @@ public function publish(array $data, Form $form): HTTPResponse

public function unpublish(array $data, Form $form): HTTPResponse
{
$className = $this->config()->get('tree_class');
$className = $this->config()->get('model_class');
/** @var SiteTree $record */
$record = DataObject::get_by_id($className, $data['ID']);

Expand Down Expand Up @@ -2075,7 +2075,7 @@ public function doRollback($data, $form)
$version = (isset($data['Version'])) ? (int) $data['Version'] : null;

/** @var SiteTree|Versioned $record */
$record = Versioned::get_latest_version($this->config()->get('tree_class'), $id);
$record = Versioned::get_latest_version($this->config()->get('model_class'), $id);
if ($record && !$record->canEdit()) {
return Security::permissionFailure($this);
}
Expand Down

0 comments on commit efdaa8e

Please sign in to comment.