From: Marcel Werk Date: Thu, 19 Sep 2024 13:37:09 +0000 (+0200) Subject: Apply suggestions from code review X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=979b046634df79e79340201ae90914d5eca1def5;p=GitHub%2FWoltLab%2FWCF.git Apply suggestions from code review --- diff --git a/wcfsetup/install/files/lib/acp/page/UserRankListPage.class.php b/wcfsetup/install/files/lib/acp/page/UserRankListPage.class.php index c636808254..a487e7e0f2 100644 --- a/wcfsetup/install/files/lib/acp/page/UserRankListPage.class.php +++ b/wcfsetup/install/files/lib/acp/page/UserRankListPage.class.php @@ -3,6 +3,7 @@ namespace wcf\acp\page; use wcf\page\AbstractGridViewPage; +use wcf\system\view\grid\AbstractGridView; use wcf\system\view\grid\UserRankGridView; /** @@ -31,8 +32,9 @@ class UserRankListPage extends AbstractGridViewPage */ public $neededModules = ['MODULE_USER_RANK']; - /** - * @inheritDoc - */ - protected string $gridViewClassName = UserRankGridView::class; + #[\Override] + protected function createGridViewController(): AbstractGridView + { + return new UserRankGridView(); + } } diff --git a/wcfsetup/install/files/lib/page/AbstractGridViewPage.class.php b/wcfsetup/install/files/lib/page/AbstractGridViewPage.class.php index 06b279f5b1..78dbb60b4d 100644 --- a/wcfsetup/install/files/lib/page/AbstractGridViewPage.class.php +++ b/wcfsetup/install/files/lib/page/AbstractGridViewPage.class.php @@ -2,15 +2,12 @@ namespace wcf\page; -use wcf\system\exception\ParentClassException; -use wcf\system\exception\SystemException; use wcf\system\request\LinkHandler; use wcf\system\view\grid\AbstractGridView; use wcf\system\WCF; abstract class AbstractGridViewPage extends AbstractPage { - protected string $gridViewClassName; protected AbstractGridView $gridView; protected int $pageNo = 1; protected string $sortField = ''; @@ -52,15 +49,7 @@ abstract class AbstractGridViewPage extends AbstractPage protected function initGridView(): void { - if (!isset($this->gridViewClassName)) { - throw new SystemException('Grid view class name not specified.'); - } - - if (!\is_subclass_of($this->gridViewClassName, AbstractGridView::class)) { - throw new ParentClassException($this->gridViewClassName, AbstractGridView::class); - } - - $this->gridView = new $this->gridViewClassName; + $this->gridView = $this->createGridViewController(); if ($this->sortField) { $this->gridView->setSortField($this->sortField); @@ -69,4 +58,6 @@ abstract class AbstractGridViewPage extends AbstractPage $this->gridView->setPageNo($this->pageNo); $this->gridView->setBaseUrl(LinkHandler::getInstance()->getControllerLink(static::class)); } + + protected abstract function createGridViewController(): AbstractGridView; }