public function WSConnectorSimpleHTTP::getOptionsForm in Web Service Data 8
Same name and namespace in other branches
- 2.0.x src/Plugin/WSConnector/WSConnectorSimpleHTTP.php \Drupal\wsdata\Plugin\WSConnector\WSConnectorSimpleHTTP::getOptionsForm()
Return the settings form provided by the connector.
Overrides WSConnectorBase::getOptionsForm
2 calls to WSConnectorSimpleHTTP::getOptionsForm()
- WSConnectorGraphQL::getOptionsForm in src/
Plugin/ WSConnector/ WSConnectorGraphQL.php - Return the settings form provided by the connector.
- WSConnectorSimpleHTTPWithLangReplacement::getOptionsForm in src/
Plugin/ WSConnector/ WSConnectorSimpleHTTPWithLangReplacement.php - Return the settings form provided by the connector.
3 methods override WSConnectorSimpleHTTP::getOptionsForm()
- WSConnectorGraphQL::getOptionsForm in src/
Plugin/ WSConnector/ WSConnectorGraphQL.php - Return the settings form provided by the connector.
- WSConnectorSimpleHTTPWithLangReplacement::getOptionsForm in src/
Plugin/ WSConnector/ WSConnectorSimpleHTTPWithLangReplacement.php - Return the settings form provided by the connector.
- WSConnectorSOAP::getOptionsForm in src/
Plugin/ WSConnector/ WSConnectorSOAP.php - Return the settings form provided by the connector.
File
- src/
Plugin/ WSConnector/ WSConnectorSimpleHTTP.php, line 101
Class
- WSConnectorSimpleHTTP
- HTTP Connector.
Namespace
Drupal\wsdata\Plugin\WSConnectorCode
public function getOptionsForm($options = []) {
$methods = $this
->getMethods();
$form['path'] = [
'#title' => $this
->t('Path'),
'#description' => $this
->t('The final endpoint will be <em>Server Endpoint/Path</em>'),
'#type' => 'textfield',
'#maxlength' => 512,
];
$form['method'] = [
'#title' => $this
->t('HTTP Method'),
'#type' => 'select',
'#options' => array_combine($methods, $methods),
];
$form['expires'] = [
'#type' => 'number',
'#title' => $this
->t('Expire'),
'#description' => $this
->t("Cache the response for number of seconds. This values will override the Cache-Control header value if it's set"),
];
if (!isset($options['headers'])) {
$options['headers'] = [];
}
$header_count = count($options['headers']);
if (isset($options['form_state'])) {
$input = $options['form_state']
->getUserInput();
if (isset($input['headers_count'])) {
$header_count = $input['headers_count'] + 1;
}
}
$form['headers'] = [
'#title' => $this
->t('Headers'),
'#type' => 'fieldset',
'#attributes' => [
'id' => 'wsconnector-headers',
],
];
$form['headers']['headers_count'] = [
'#type' => 'hidden',
'#value' => $header_count,
];
for ($i = 0; $i < $header_count; $i++) {
$form['headers'][$i] = [
'#title' => 'header',
'#type' => 'fieldset',
];
$form['headers'][$i]['key_' . $i] = [
'#type' => 'textfield',
'#title' => $this
->t('Key'),
];
$form['headers'][$i]['value_' . $i] = [
'#type' => 'textfield',
'#title' => $this
->t('Value'),
];
}
if (isset($options['form_state'])) {
$form['headers']['add_another'] = [
'#type' => 'submit',
'#value' => $this
->t('Add another'),
'#ajax' => [
'callback' => '\\Drupal\\wsdata\\Plugin\\WSConnector\\WSConnectorSimpleHTTP::wsconnectorHttpHeaderAjaxCallback',
'wrapper' => 'wsconnector-headers',
],
'#limit_validation_errors' => [],
];
}
return $form;
}