1515use OCA \TermsOfService \Db \Mapper \SignatoryMapper ;
1616use OCA \TermsOfService \Db \Mapper \TermsMapper ;
1717use OCA \TermsOfService \Exceptions \TermsNotFoundException ;
18- use OCP \AppFramework \Controller ;
18+ use OCP \AppFramework \OCSController ;
1919use OCP \AppFramework \Http ;
20- use OCP \AppFramework \Http \JSONResponse ;
20+ use OCP \AppFramework \Http \DataResponse ;
2121use OCP \IConfig ;
2222use OCP \IRequest ;
2323use OCP \L10N \IFactory ;
2424use OCA \TermsOfService \Events \TermsCreatedEvent ;
2525use OCP \EventDispatcher \IEventDispatcher ;
2626
27- class TermsController extends Controller {
27+ class TermsController extends OCSController {
2828 /** @var IFactory */
2929 private $ factory ;
3030 /** @var TermsMapper */
@@ -71,9 +71,9 @@ public function __construct(string $appName,
7171
7272 /**
7373 * @PublicPage
74- * @return JSONResponse
74+ * @return DataResponse
7575 */
76- public function index (): JSONResponse {
76+ public function index (): DataResponse {
7777 $ currentCountry = $ this ->countryDetector ->getCountry ();
7878 $ countryTerms = $ this ->termsMapper ->getTermsForCountryCode ($ currentCountry );
7979
@@ -87,35 +87,35 @@ public function index(): JSONResponse {
8787 'languages ' => $ this ->languageMapper ->getLanguages (),
8888 'hasSigned ' => $ this ->checker ->currentUserHasSigned (),
8989 ];
90- return new JSONResponse ($ response );
90+ return new DataResponse ($ response );
9191 }
9292
9393 /**
94- * @return JSONResponse
94+ * @return DataResponse
9595 */
96- public function getAdminFormData (): JSONResponse {
96+ public function getAdminFormData (): DataResponse {
9797 $ response = [
9898 'terms ' => $ this ->termsMapper ->getTerms (),
9999 'countries ' => $ this ->countryMapper ->getCountries (),
100100 'languages ' => $ this ->languageMapper ->getLanguages (),
101101 'tos_on_public_shares ' => $ this ->config ->getAppValue (Application::APPNAME , 'tos_on_public_shares ' , '0 ' ),
102102 'tos_for_users ' => $ this ->config ->getAppValue (Application::APPNAME , 'tos_for_users ' , '1 ' ),
103103 ];
104- return new JSONResponse ($ response );
104+ return new DataResponse ($ response );
105105 }
106106
107107 /**
108108 * @param int $id
109- * @return JSONResponse
109+ * @return DataResponse
110110 */
111- public function destroy (int $ id ): JSONResponse {
111+ public function destroy (int $ id ): DataResponse {
112112 $ terms = new Terms ();
113113 $ terms ->setId ($ id );
114114
115115 $ this ->termsMapper ->delete ($ terms );
116116 $ this ->signatoryMapper ->deleteTerm ($ terms );
117117
118- return new JSONResponse ();
118+ return new DataResponse ();
119119 }
120120 protected function createTermsCreatedEvent (): TermsCreatedEvent {
121121 return new TermsCreatedEvent ();
@@ -125,11 +125,11 @@ protected function createTermsCreatedEvent(): TermsCreatedEvent {
125125 * @param string $countryCode
126126 * @param string $languageCode
127127 * @param string $body
128- * @return JSONResponse
128+ * @return DataResponse
129129 */
130130 public function create (string $ countryCode ,
131131 string $ languageCode ,
132- string $ body ): JSONResponse {
132+ string $ body ): DataResponse {
133133 $ update = false ;
134134 try {
135135 // Update terms
@@ -141,7 +141,7 @@ public function create(string $countryCode,
141141 }
142142
143143 if (!$ this ->countryMapper ->isValidCountry ($ countryCode ) || !$ this ->languageMapper ->isValidLanguage ($ languageCode )) {
144- return new JSONResponse ([], Http::STATUS_EXPECTATION_FAILED );
144+ return new DataResponse ([], Http::STATUS_EXPECTATION_FAILED );
145145 }
146146
147147 $ terms ->setCountryCode ($ countryCode );
@@ -157,6 +157,6 @@ public function create(string $countryCode,
157157 $ event = $ this ->createTermsCreatedEvent ();
158158 $ this ->eventDispatcher ->dispatchTyped ($ event );
159159
160- return new JSONResponse ($ terms );
160+ return new DataResponse ($ terms );
161161 }
162162}
0 commit comments