22
33namespace wcf \page ;
44
5+ use Laminas \Diactoros \Response \RedirectResponse ;
56use wcf \data \DatabaseObject ;
67use wcf \data \DatabaseObjectList ;
78use wcf \data \object \type \ObjectTypeCache ;
9+ use wcf \event \moderation \DeletedItemsCollecting ;
10+ use wcf \system \event \EventHandler ;
811use wcf \system \exception \IllegalLinkException ;
12+ use wcf \system \moderation \DeletedItemsBoxComponent ;
913use wcf \system \WCF ;
1014
1115/**
@@ -42,23 +46,36 @@ public function readParameters()
4246 {
4347 parent ::readParameters ();
4448
45- // get object type
4649 if (isset ($ _REQUEST ['objectType ' ])) {
4750 $ this ->objectType = ObjectTypeCache::getInstance ()->getObjectTypeByName (
4851 'com.woltlab.wcf.deletedContent ' ,
4952 $ _REQUEST ['objectType ' ]
5053 );
54+
55+ if ($ this ->objectType === null ) {
56+ throw new IllegalLinkException ();
57+ }
5158 } else {
52- // use first object type
53- $ objectTypes = ObjectTypeCache::getInstance ()->getObjectTypes ('com.woltlab.wcf.deletedContent ' );
54- if (!empty ($ objectTypes )) {
55- $ this ->objectType = \reset ($ objectTypes );
59+ $ link = $ this ->getFirstTypeLink ();
60+ if ($ link === null ) {
61+ throw new IllegalLinkException ();
5662 }
63+
64+ return new RedirectResponse ($ link );
5765 }
66+ }
5867
59- if ($ this ->objectType === null ) {
60- throw new IllegalLinkException ();
68+ private function getFirstTypeLink (): ?string
69+ {
70+ $ event = new DeletedItemsCollecting ();
71+ EventHandler::getInstance ()->fire ($ event );
72+ $ types = $ event ->getTypes ();
73+
74+ if ($ types === []) {
75+ return null ;
6176 }
77+
78+ return reset ($ types )->link ;
6279 }
6380
6481 /**
@@ -77,7 +94,7 @@ public function assignVariables()
7794 parent ::assignVariables ();
7895
7996 WCF ::getTPL ()->assign ([
80- 'availableObjectTypes ' => ObjectTypeCache:: getInstance ()-> getObjectTypes ( ' com.woltlab.wcf.deletedContent ' ),
97+ 'deletedItemsBox ' => new DeletedItemsBoxComponent ( $ this -> objectType -> objectType ),
8198 'objectType ' => $ this ->objectType ->objectType ,
8299 'resultListTemplateName ' => $ this ->objectType ->getProcessor ()->getTemplateName (),
83100 'resultListApplication ' => $ this ->objectType ->getProcessor ()->getApplication (),
0 commit comments