66 */
77namespace OCA \Deck \Controller ;
88
9+ use OCA \Deck \Db \Attachment ;
910use OCA \Deck \Service \AttachmentService ;
1011use OCP \AppFramework \ApiController ;
1112use OCP \AppFramework \Http ;
13+ use OCP \AppFramework \Http \Attribute \CORS ;
14+ use OCP \AppFramework \Http \Attribute \NoAdminRequired ;
15+ use OCP \AppFramework \Http \Attribute \NoCSRFRequired ;
1216use OCP \AppFramework \Http \DataResponse ;
1317use OCP \IRequest ;
1418
@@ -21,72 +25,52 @@ public function __construct(
2125 parent ::__construct ($ appName , $ request );
2226 }
2327
24- /**
25- * @NoAdminRequired
26- * @CORS
27- * @NoCSRFRequired
28- *
29- */
30- public function getAll ($ apiVersion ) {
28+ #[NoAdminRequired]
29+ #[CORS ]
30+ #[NoCSRFRequired]
31+ public function getAll (string $ apiVersion ): DataResponse {
3132 $ attachment = $ this ->attachmentService ->findAll ($ this ->request ->getParam ('cardId ' ), true );
3233 if ($ apiVersion === '1.0 ' ) {
33- $ attachment = array_filter ($ attachment , function ($ attachment ) {
34- return $ attachment ->getType () === 'deck_file ' ;
35- });
34+ $ attachment = array_filter ($ attachment , fn (Attachment $ attachment ): bool => $ attachment ->getType () === 'deck_file ' );
3635 }
3736 return new DataResponse ($ attachment , HTTP ::STATUS_OK );
3837 }
3938
40- /**
41- * @NoAdminRequired
42- * @CORS
43- * @NoCSRFRequired
44- *
45- */
46- public function display ($ cardId , $ attachmentId , $ type = 'deck_file ' ) {
39+ #[NoAdminRequired]
40+ #[CORS ]
41+ #[NoCSRFRequired]
42+ public function display (int $ cardId , int $ attachmentId , string $ type = 'deck_file ' ) {
4743 return $ this ->attachmentService ->display ($ cardId , $ attachmentId , $ type );
4844 }
4945
50- /**
51- * @NoAdminRequired
52- * @CORS
53- * @NoCSRFRequired
54- *
55- */
56- public function create ($ cardId , $ type , $ data ) {
46+ #[NoAdminRequired]
47+ #[CORS ]
48+ #[NoCSRFRequired]
49+ public function create (int $ cardId , string $ type , string $ data ): DataResponse {
5750 $ attachment = $ this ->attachmentService ->create ($ cardId , $ type , $ data );
5851 return new DataResponse ($ attachment , HTTP ::STATUS_OK );
5952 }
6053
61- /**
62- * @NoAdminRequired
63- * @CORS
64- * @NoCSRFRequired
65- *
66- */
67- public function update ($ cardId , $ attachmentId , $ data , $ type = 'deck_file ' ) {
54+ #[NoAdminRequired]
55+ #[CORS ]
56+ #[NoCSRFRequired]
57+ public function update (int $ cardId , int $ attachmentId , string $ data , string $ type = 'deck_file ' ): DataResponse {
6858 $ attachment = $ this ->attachmentService ->update ($ cardId , $ attachmentId , $ data , $ type );
6959 return new DataResponse ($ attachment , HTTP ::STATUS_OK );
7060 }
7161
72- /**
73- * @NoAdminRequired
74- * @CORS
75- * @NoCSRFRequired
76- *
77- */
78- public function delete ($ cardId , $ attachmentId , $ type = 'deck_file ' ) {
62+ #[NoAdminRequired]
63+ #[CORS ]
64+ #[NoCSRFRequired]
65+ public function delete (int $ cardId , int $ attachmentId , string $ type = 'deck_file ' ): DataResponse {
7966 $ attachment = $ this ->attachmentService ->delete ($ cardId , $ attachmentId , $ type );
8067 return new DataResponse ($ attachment , HTTP ::STATUS_OK );
8168 }
8269
83- /**
84- * @NoAdminRequired
85- * @CORS
86- * @NoCSRFRequired
87- *
88- */
89- public function restore ($ cardId , $ attachmentId , $ type = 'deck_file ' ) {
70+ #[NoAdminRequired]
71+ #[CORS ]
72+ #[NoCSRFRequired]
73+ public function restore (int $ cardId , int $ attachmentId , string $ type = 'deck_file ' ): DataResponse {
9074 $ attachment = $ this ->attachmentService ->restore ($ cardId , $ attachmentId , $ type );
9175 return new DataResponse ($ attachment , HTTP ::STATUS_OK );
9276 }
0 commit comments