use wcf\data\DatabaseObject;
use wcf\data\DatabaseObjectList;
-use wcf\system\exception\ParentClassException;
-use wcf\system\exception\SystemException;
abstract class DatabaseObjectListGridView extends AbstractGridView
{
- protected string $objectListClassName;
protected DatabaseObjectList $objectList;
private int $objectCount;
protected function initObjectList(): void
{
- if (!isset($this->objectListClassName)) {
- throw new SystemException('Database object list class name not specified.');
- }
-
- if (!\is_subclass_of($this->objectListClassName, DatabaseObjectList::class)) {
- throw new ParentClassException($this->objectListClassName, DatabaseObjectList::class);
- }
-
- $this->objectList = new $this->objectListClassName;
+ $this->objectList = $this->createObjectList();
$this->objectList->sqlLimit = $this->getRowsPerPage();
$this->objectList->sqlOffset = ($this->getPageNo() - 1) * $this->getRowsPerPage();
if ($this->getSortField()) {
return $this->objectList;
}
+
+ protected abstract function createObjectList(): DatabaseObjectList;
}
namespace wcf\system\view\grid;
use wcf\acp\form\UserRankEditForm;
+use wcf\data\DatabaseObjectList;
use wcf\data\user\group\UserGroup;
use wcf\data\user\rank\UserRank;
use wcf\data\user\rank\UserRankList;
final class UserRankGridView extends DatabaseObjectListGridView
{
- protected string $objectListClassName = UserRankList::class;
-
#[\Override]
protected function init(): void
{
$this->setSortField('rankTitle');
}
+ #[\Override]
public function isAccessible(): bool
{
return \MODULE_USER_RANK && WCF::getSession()->getPermission('admin.user.rank.canManageRank');
}
+
+ #[\Override]
+ protected function createObjectList(): DatabaseObjectList
+ {
+ return new UserRankList();
+ }
}