From b6bd643e2160d5824dfa6f3dcc0465b50fbe51f6 Mon Sep 17 00:00:00 2001 From: Ben Thomson Date: Sun, 30 Dec 2018 16:25:01 +0800 Subject: [PATCH] Rename prepareModel to prepareQuery, deprecate prepareModel --- modules/backend/widgets/Lists.php | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/modules/backend/widgets/Lists.php b/modules/backend/widgets/Lists.php index d859a37d9..fd656a8ff 100644 --- a/modules/backend/widgets/Lists.php +++ b/modules/backend/widgets/Lists.php @@ -343,7 +343,7 @@ class Lists extends WidgetBase /** * Applies any filters to the model. */ - public function prepareModel() + public function prepareQuery() { $query = $this->model->newQuery(); $primaryTable = $this->model->getTable(); @@ -566,16 +566,22 @@ class Lists extends WidgetBase return $query; } + public function prepareModel() + { + traceLog('Method ' . __METHOD__ . '() has been deprecated, please use the ' . __CLASS__ . '::prepareQuery() method instead.'); + return $this->prepareQuery(); + } + /** * Returns all the records from the supplied model, after filtering. * @return Collection */ protected function getRecords() { - $model = $this->prepareModel(); + $query = $this->prepareQuery(); if ($this->showTree) { - $records = $model->getNested(); + $records = $query->getNested(); } elseif ($this->showPagination) { $method = $this->showPageNumbers ? 'paginate' : 'simplePaginate'; @@ -584,10 +590,10 @@ class Lists extends WidgetBase // Restore the last visited page from the session if available. $currentPageNumber = $this->getSession('lastVisitedPage'); } - $records = $model->{$method}($this->recordsPerPage, $currentPageNumber); + $records = $query->{$method}($this->recordsPerPage, $currentPageNumber); } else { - $records = $model->get(); + $records = $query->get(); } /**