@@ -135,6 +135,8 @@ public static function addSettingsFormFields(QuickForm $form)
135135 . 'https://www.servicenow.com/docs/bundle/yokohama-platform-user-interface/page/use/using-lists/concept/c_EncodedQueryStrings.html ' ,
136136 ]
137137 );
138+
139+ static ::addProxy ($ form );
138140 }
139141
140142 /**
@@ -201,6 +203,10 @@ private function getRecordsFromTable(): array
201203 'token ' => $ this ->getSetting ('servicenow_token ' ),
202204 'username ' => $ this ->getSetting ('servicenow_username ' ),
203205 'password ' => $ this ->getSetting ('servicenow_password ' ),
206+ 'proxy_type ' => $ this ->getSetting ('proxy_type ' ),
207+ 'proxy_address ' => $ this ->getSetting ('proxy ' ),
208+ 'proxy_user ' => $ this ->getSetting ('proxy_user ' ),
209+ 'proxy_password ' => $ this ->getSetting ('proxy_pass ' ),
204210 ];
205211
206212 $ client = new Servicenow (
@@ -220,6 +226,50 @@ private function getRecordsFromTable(): array
220226 ]
221227 );
222228
229+
230+
223231 return json_decode ($ result )->result ;
224232 }
233+
234+ protected static function addProxy (QuickForm $ form )
235+ {
236+ $ form ->addElement ('select ' , 'proxy_type ' , [
237+ 'label ' => $ form ->translate ('Proxy ' ),
238+ 'description ' => $ form ->translate (
239+ 'In case your API is only reachable through a proxy, please '
240+ . ' choose it \'s protocol right here '
241+ ),
242+ 'multiOptions ' => $ form ->optionalEnum ([
243+ 'HTTP ' => $ form ->translate ('HTTP proxy ' ),
244+ 'SOCKS5 ' => $ form ->translate ('SOCKS5 proxy ' ),
245+ ]),
246+ 'class ' => 'autosubmit '
247+ ]);
248+
249+ $ proxyType = $ form ->getSentOrObjectSetting ('proxy_type ' );
250+
251+ if ($ proxyType ) {
252+ $ form ->addElement ('text ' , 'proxy ' , [
253+ 'label ' => $ form ->translate ('Proxy Address ' ),
254+ 'description ' => $ form ->translate (
255+ 'Hostname, IP or <host>:<port> '
256+ ),
257+ 'required ' => true ,
258+ ]);
259+ if ($ proxyType === 'HTTP ' ) {
260+ $ form ->addElement ('text ' , 'proxy_user ' , [
261+ 'label ' => $ form ->translate ('Proxy Username ' ),
262+ 'description ' => $ form ->translate (
263+ 'In case your proxy requires authentication, please '
264+ . ' configure this here '
265+ ),
266+ ]);
267+
268+ $ form ->addElement ('storedPassword ' , 'proxy_pass ' , [
269+ 'label ' => $ form ->translate ('Proxy Password ' ),
270+ 'required ' => strlen ((string ) $ form ->getSentOrObjectSetting ('proxy_user ' )) > 0
271+ ]);
272+ }
273+ }
274+ }
225275}
0 commit comments