|
2 | 2 |
|
3 | 3 | namespace wcf\acp\form; |
4 | 4 |
|
5 | | -use wcf\acp\page\UserRankListPage; |
6 | 5 | use CuyZ\Valinor\Mapper\MappingError; |
| 6 | +use wcf\acp\page\UserRankListPage; |
| 7 | +use wcf\data\IStorableObject; |
7 | 8 | use wcf\data\user\rank\UserRank; |
8 | 9 | use wcf\http\Helper; |
9 | 10 | use wcf\system\exception\IllegalLinkException; |
| 11 | +use wcf\system\form\builder\data\processor\CustomFormDataProcessor; |
| 12 | +use wcf\system\form\builder\IFormDocument; |
10 | 13 | use wcf\system\interaction\admin\UserRankInteractions; |
11 | 14 | use wcf\system\interaction\StandaloneInteractionContextMenuView; |
12 | 15 | use wcf\system\request\LinkHandler; |
@@ -58,6 +61,34 @@ public function readParameters() |
58 | 61 | } |
59 | 62 | } |
60 | 63 |
|
| 64 | + #[\Override] |
| 65 | + protected function finalizeForm() |
| 66 | + { |
| 67 | + parent::finalizeForm(); |
| 68 | + |
| 69 | + // The `DeleteInteraction` in `UserRankInteractions` outputs the title and would otherwise execute an additional SQL query. |
| 70 | + $this->form->getDataHandler() |
| 71 | + ->addProcessor( |
| 72 | + new CustomFormDataProcessor( |
| 73 | + 'setRankTitlesFormDataProcessor', |
| 74 | + null, |
| 75 | + static function (IFormDocument $document, array $data, IStorableObject $object) { |
| 76 | + \assert($object instanceof UserRank); |
| 77 | + |
| 78 | + if (\is_array($data['rankTitle'])) { |
| 79 | + foreach ($data['rankTitle'] as $languageID => $rankTitle) { |
| 80 | + $object->setRankTitle($languageID, $rankTitle); |
| 81 | + } |
| 82 | + } else { |
| 83 | + $object->setRankTitle(null, $data['rankTitle']); |
| 84 | + } |
| 85 | + |
| 86 | + return $data; |
| 87 | + } |
| 88 | + ) |
| 89 | + ); |
| 90 | + } |
| 91 | + |
61 | 92 | /** |
62 | 93 | * @inheritDoc |
63 | 94 | */ |
|
0 commit comments