Skip to content

Commit 4436591

Browse files
committed
Update custom renderer implementations
1 parent dc49102 commit 4436591

File tree

4 files changed

+34
-37
lines changed

4 files changed

+34
-37
lines changed

wcfsetup/install/files/lib/system/gridView/admin/CronjobLogGridView.class.php

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
use wcf\data\cronjob\I18nCronjobList;
77
use wcf\data\cronjob\log\CronjobLog;
88
use wcf\data\cronjob\log\CronjobLogList;
9+
use wcf\data\DatabaseObject;
910
use wcf\data\DatabaseObjectList;
1011
use wcf\event\gridView\admin\CronjobLogGridViewInitialized;
1112
use wcf\event\IPsr14Event;
@@ -47,7 +48,7 @@ public function __construct()
4748
new class($availableCronjobs) extends DefaultColumnRenderer {
4849
public function __construct(private readonly array $availableCronjobs) {}
4950

50-
public function render(mixed $value, mixed $context = null): string
51+
public function render(mixed $value, DatabaseObject $row): string
5152
{
5253
return $this->availableCronjobs[$value];
5354
}
@@ -67,18 +68,18 @@ public function render(mixed $value, mixed $context = null): string
6768
]))
6869
->renderer([
6970
new class extends DefaultColumnRenderer {
70-
public function render(mixed $value, mixed $context = null): string
71+
public function render(mixed $value, DatabaseObject $row): string
7172
{
72-
\assert($context instanceof CronjobLog);
73+
\assert($row instanceof CronjobLog);
7374

74-
if ($context->success) {
75+
if ($row->success) {
7576
return '<span class="badge green">' . WCF::getLanguage()->get('wcf.acp.cronjob.log.success') . '</span>';
7677
}
77-
if ($context->error) {
78+
if ($row->error) {
7879
$label = WCF::getLanguage()->get('wcf.acp.cronjob.log.error');
79-
$buttonId = 'cronjobLogErrorButton' . $context->cronjobLogID;
80-
$id = 'cronjobLogError' . $context->cronjobLogID;
81-
$error = StringUtil::encodeHTML($context->error);
80+
$buttonId = 'cronjobLogErrorButton' . $row->cronjobLogID;
81+
$id = 'cronjobLogError' . $row->cronjobLogID;
82+
$error = StringUtil::encodeHTML($row->error);
8283
$dialogTitle = StringUtil::encodeJS(WCF::getLanguage()->get('wcf.acp.cronjob.log.error.details'));
8384

8485
return <<<HTML

wcfsetup/install/files/lib/system/gridView/admin/ModificationLogGridView.class.php

Lines changed: 8 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -62,10 +62,10 @@ public function __construct()
6262
->renderer([
6363
new class extends DefaultColumnRenderer {
6464
#[\Override]
65-
public function render(mixed $value, mixed $context = null): string
65+
public function render(mixed $value, DatabaseObject $row): string
6666
{
67-
\assert($context instanceof DatabaseObjectDecorator);
68-
$log = $context->getDecoratedObject();
67+
\assert($row instanceof DatabaseObjectDecorator);
68+
$log = $row->getDecoratedObject();
6969
\assert($log instanceof ModificationLog);
7070
$objectType = ObjectTypeCache::getInstance()->getObjectType($log->objectTypeID);
7171
if (!$objectType) {
@@ -114,12 +114,6 @@ public function applyFilter(DatabaseObjectList $list, string $id, string $value)
114114
}
115115
}
116116

117-
#[\Override]
118-
public function matches(string $filterValue, string $rowValue): bool
119-
{
120-
throw new LogicException('unreachable');
121-
}
122-
123117
#[\Override]
124118
public function renderValue(string $value): string
125119
{
@@ -136,17 +130,17 @@ public function renderValue(string $value): string
136130
->renderer([
137131
new class extends DefaultColumnRenderer implements ILinkColumnRenderer {
138132
#[\Override]
139-
public function render(mixed $value, mixed $context = null): string
133+
public function render(mixed $value, DatabaseObject $row): string
140134
{
141-
\assert($context instanceof IViewableModificationLog);
142-
if ($context->getAffectedObject() === null) {
135+
\assert($row instanceof IViewableModificationLog);
136+
if ($row->getAffectedObject() === null) {
143137
return WCF::getLanguage()->get('wcf.acp.modificationLog.affectedObject.unknown');
144138
}
145139

146140
return \sprintf(
147141
'<a href="%s">%s</a>',
148-
StringUtil::encodeHTML($context->getAffectedObject()->getLink()),
149-
StringUtil::encodeHTML($context->getAffectedObject()->getTitle())
142+
StringUtil::encodeHTML($row->getAffectedObject()->getLink()),
143+
StringUtil::encodeHTML($row->getAffectedObject()->getTitle())
150144
);
151145
}
152146
},

wcfsetup/install/files/lib/system/gridView/admin/UserOptionGridView.class.php

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
namespace wcf\system\gridView\admin;
44

55
use wcf\acp\form\UserOptionEditForm;
6+
use wcf\data\DatabaseObject;
67
use wcf\data\DatabaseObjectList;
78
use wcf\data\user\option\UserOption;
89
use wcf\data\user\option\UserOptionList;
@@ -45,11 +46,11 @@ public function __construct()
4546
->titleColumn()
4647
->renderer([
4748
new class extends DefaultColumnRenderer {
48-
public function render(mixed $value, mixed $context = null): string
49+
public function render(mixed $value, DatabaseObject $row): string
4950
{
50-
\assert($context instanceof UserOption);
51+
\assert($row instanceof UserOption);
5152

52-
return StringUtil::encodeHTML($context->getTitle());
53+
return StringUtil::encodeHTML($row->getTitle());
5354
}
5455
}
5556
]),
@@ -58,12 +59,12 @@ public function render(mixed $value, mixed $context = null): string
5859
->sortable()
5960
->renderer([
6061
new class extends DefaultColumnRenderer {
61-
public function render(mixed $value, mixed $context = null): string
62+
public function render(mixed $value, DatabaseObject $row): string
6263
{
63-
\assert($context instanceof UserOption);
64+
\assert($row instanceof UserOption);
6465

6566
return StringUtil::encodeHTML(
66-
WCF::getLanguage()->get('wcf.user.option.category.' . $context->categoryName)
67+
WCF::getLanguage()->get('wcf.user.option.category.' . $row->categoryName)
6768
);
6869
}
6970
}

wcfsetup/install/files/lib/system/gridView/admin/UserRankGridView.class.php

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
namespace wcf\system\gridView\admin;
44

55
use wcf\acp\form\UserRankEditForm;
6+
use wcf\data\DatabaseObject;
67
use wcf\data\DatabaseObjectList;
78
use wcf\data\user\group\UserGroup;
89
use wcf\data\user\rank\I18nUserRankList;
@@ -47,12 +48,12 @@ public function __construct()
4748
->filter(new I18nTextFilter())
4849
->renderer([
4950
new class extends DefaultColumnRenderer {
50-
public function render(mixed $value, mixed $context = null): string
51+
public function render(mixed $value, DatabaseObject $row): string
5152
{
52-
\assert($context instanceof UserRank);
53+
\assert($row instanceof UserRank);
5354

54-
return '<span class="badge label' . ($context->cssClassName ? ' ' . $context->cssClassName : '') . '">'
55-
. StringUtil::encodeHTML($context->getTitle())
55+
return '<span class="badge label' . ($row->cssClassName ? ' ' . $row->cssClassName : '') . '">'
56+
. StringUtil::encodeHTML($row->getTitle())
5657
. '<span>';
5758
}
5859
}
@@ -62,11 +63,11 @@ public function render(mixed $value, mixed $context = null): string
6263
->sortable()
6364
->renderer([
6465
new class extends DefaultColumnRenderer {
65-
public function render(mixed $value, mixed $context = null): string
66+
public function render(mixed $value, DatabaseObject $row): string
6667
{
67-
\assert($context instanceof UserRank);
68+
\assert($row instanceof UserRank);
6869

69-
return $context->rankImage ? $context->getImage() : '';
70+
return $row->rankImage ? $row->getImage() : '';
7071
}
7172
},
7273
]),
@@ -76,7 +77,7 @@ public function render(mixed $value, mixed $context = null): string
7677
->filter(new SelectFilter($this->getAvailableUserGroups()))
7778
->renderer([
7879
new class extends DefaultColumnRenderer {
79-
public function render(mixed $value, mixed $context = null): string
80+
public function render(mixed $value, DatabaseObject $row): string
8081
{
8182
return StringUtil::encodeHTML(UserGroup::getGroupByID($value)->getName());
8283
}
@@ -87,7 +88,7 @@ public function render(mixed $value, mixed $context = null): string
8788
->sortable()
8889
->renderer([
8990
new class extends DefaultColumnRenderer {
90-
public function render(mixed $value, mixed $context = null): string
91+
public function render(mixed $value, DatabaseObject $row): string
9192
{
9293
if (!$value) {
9394
return '';

0 commit comments

Comments
 (0)