final protected function SwaggerUIFormatterTrait::alterSettingsForm in Swagger UI Field Formatter 8.3
Same name and namespace in other branches
- 8.2 src/Plugin/Field/FieldFormatter/SwaggerUIFormatterTrait.php \Drupal\swagger_ui_formatter\Plugin\Field\FieldFormatter\SwaggerUIFormatterTrait::alterSettingsForm()
Adds Swagger UI specific configurations to the settings form.
Parameters
array $form: The form render array.
\Drupal\Core\Form\FormStateInterface $form_state: The form state.
\Drupal\Core\Field\FormatterInterface $formatter: The current field formatter.
\Drupal\Core\Field\FieldDefinitionInterface $field_definition: The field definition in the current field formatter.
2 calls to SwaggerUIFormatterTrait::alterSettingsForm()
- SwaggerUIFileFormatter::settingsForm in src/
Plugin/ Field/ FieldFormatter/ SwaggerUIFileFormatter.php - Returns a form to configure settings for the formatter.
- SwaggerUILinkFormatter::settingsForm in src/
Plugin/ Field/ FieldFormatter/ SwaggerUILinkFormatter.php - Returns a form to configure settings for the formatter.
File
- src/
Plugin/ Field/ FieldFormatter/ SwaggerUIFormatterTrait.php, line 62
Class
- SwaggerUIFormatterTrait
- Provides common methods for Swagger UI field formatters.
Namespace
Drupal\swagger_ui_formatter\Plugin\Field\FieldFormatterCode
protected final function alterSettingsForm(array &$form, FormStateInterface $form_state, FormatterInterface $formatter, FieldDefinitionInterface $field_definition) : void {
$form['validator'] = [
'#type' => 'select',
'#title' => $this
->t('Validator'),
'#description' => $this
->t("Default=Swagger.io's online validator, None=No validation, Custom=Provide a custom validator url"),
'#default_value' => $formatter
->getSetting('validator'),
'#options' => [
'none' => $this
->t('None'),
'default' => $this
->t('Default'),
'custom' => $this
->t('Custom'),
],
];
$form['validator_url'] = [
'#type' => 'textfield',
'#title' => $this
->t('Validator URL'),
'#description' => $this
->t('The custom validator url to be used to validated the swagger files.'),
'#default_value' => $formatter
->getSetting('validator_url'),
'#states' => [
'visible' => [
':input[name="fields[' . $field_definition
->getName() . '][settings_edit_form][settings][validator]"]' => [
'value' => 'custom',
],
],
],
];
$form['doc_expansion'] = [
'#type' => 'select',
'#title' => $this
->t('Doc Expansion'),
'#description' => $this
->t('Controls how the API listing is displayed.'),
'#default_value' => $formatter
->getSetting('doc_expansion'),
'#options' => [
'none' => $this
->t('None - Expands nothing'),
'list' => $this
->t('List - Expands only tags'),
'full' => $this
->t('Full - Expands tags and operations'),
],
];
$form['show_top_bar'] = [
'#type' => 'checkbox',
'#title' => $this
->t('Show Top Bar'),
'#description' => $this
->t('Controls whether the Swagger UI top bar should be displayed or not.'),
'#default_value' => $formatter
->getSetting('show_top_bar'),
];
$form['sort_tags_by_name'] = [
'#type' => 'checkbox',
'#title' => $this
->t('Sort tags by name'),
'#description' => $this
->t('Controls whether the tag groups should be ordered alphabetically or not.'),
'#default_value' => $formatter
->getSetting('sort_tags_by_name'),
];
$form['supported_submit_methods'] = [
'#type' => 'checkboxes',
'#title' => $this
->t('Try it out support for HTTP Methods'),
'#description' => $this
->t('List of HTTP methods that have the Try it out feature enabled. Selecting none disables Try it out for all operations. This does not filter the operations from the display.'),
'#default_value' => $formatter
->getSetting('supported_submit_methods'),
'#options' => [
'get' => $this
->t('GET'),
'put' => $this
->t('PUT'),
'post' => $this
->t('POST'),
'delete' => $this
->t('DELETE'),
'options' => $this
->t('OPTIONS'),
'head' => $this
->t('HEAD'),
'patch' => $this
->t('PATCH'),
],
];
}