From 4ab464cede7be05e3420f56994bd1e19c5c30e02 Mon Sep 17 00:00:00 2001 From: empower-josh <45080572+empower-josh@users.noreply.github.com> Date: Wed, 4 Dec 2019 01:29:24 -0700 Subject: [PATCH] Add public methods to access Lists widget's sort direction & column (#4746) Credit to @empower-josh. --- modules/backend/widgets/Lists.php | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/modules/backend/widgets/Lists.php b/modules/backend/widgets/Lists.php index f1946d747..59fc31194 100644 --- a/modules/backend/widgets/Lists.php +++ b/modules/backend/widgets/Lists.php @@ -1517,7 +1517,7 @@ class Lists extends WidgetBase /** * Returns the current sorting column, saved in a session or cached. */ - protected function getSortColumn() + public function getSortColumn() { if (!$this->isSortable()) { return false; @@ -1564,6 +1564,14 @@ class Lists extends WidgetBase return $this->sortColumn; } + /* + * Returns the current sort direction or default of 'asc' + */ + public function getSortDirection() + { + return $this->sortDirection ?? 'asc'; + } + /** * Returns true if the column can be sorted. */