class OpenReadSpeakerSettingsForm in Open ReadSpeaker 8
Class OpenReadSpeakerSettingsForm.
@package Drupal\open_readspeaker\Form
Hierarchy
- class \Drupal\Core\Form\FormBase implements ContainerInjectionInterface, FormInterface uses DependencySerializationTrait, LoggerChannelTrait, MessengerTrait, LinkGeneratorTrait, RedirectDestinationTrait, UrlGeneratorTrait, StringTranslationTrait
- class \Drupal\Core\Form\ConfigFormBase uses ConfigFormBaseTrait
- class \Drupal\open_readspeaker\Form\OpenReadSpeakerSettingsForm
- class \Drupal\Core\Form\ConfigFormBase uses ConfigFormBaseTrait
Expanded class hierarchy of OpenReadSpeakerSettingsForm
1 string reference to 'OpenReadSpeakerSettingsForm'
File
- src/
Form/ OpenReadSpeakerSettingsForm.php, line 14
Namespace
Drupal\open_readspeaker\FormView source
class OpenReadSpeakerSettingsForm extends ConfigFormBase {
/**
* {@inheritdoc}
*/
protected function getEditableConfigNames() {
return [
'open_readspeaker.settings',
];
}
/**
* {@inheritdoc}
*/
public function getFormId() {
return 'open_read_speaker_settings_form';
}
/**
* {@inheritdoc}
*/
public function buildForm(array $form, FormStateInterface $form_state) {
$config = $this
->config('open_readspeaker.settings');
$language_options = [
'none' => $this
->t('Select a language'),
'ar_ar' => $this
->t('@arabic - Arabic', [
'@arabic' => urldecode('%D8%B9%D8%B1%D8%A8%D9%8A'),
]),
'ca_es' => $this
->t('Català - Catalan'),
'da_dk' => $this
->t('Dansk - Danish'),
'de_de' => $this
->t('Deutsch - German'),
'en_in' => $this
->t('English (Indian) - English'),
'en_us' => $this
->t('English (US) - English'),
'en_uk' => $this
->t('English (British) - English'),
'en_au' => $this
->t('English (Australia) - English'),
'es_co' => $this
->t('Español (de Colombia) - Spanish'),
'es_es' => $this
->t('Español (de España) - Spanish'),
'es_mx' => $this
->t('Español (de Mexico) - Spanish'),
'es_eu' => $this
->t('Euskara - Basque'),
'es_us' => $this
->t('Español (de US) - Spanish'),
'el_gr' => $this
->t('Ελληνικά - Greek'),
'fo_fo' => $this
->t('Azerbaijani - Faroese'),
'fi_fi' => $this
->t('Suomi - Finnish'),
'fr_fr' => $this
->t('Français - French'),
'fr_be' => $this
->t('Français (Belge) - French (Belgian)'),
'fy_nl' => $this
->t('Frysk - Frisian'),
'gl_es' => $this
->t('Galego - Galician'),
'hi_in' => $this
->t('@hindi - Hindi', [
'@hindi' => urldecode('%E0%A4%B9%E0%A4%BF%E0%A4%A8%E0%A5%8D%E0%A4%A6%E0%A5%80%20(%E0%A4%AD%E0%A4%BE%E0%A4%B0%E0%A4%A4)'),
]),
'it_it' => $this
->t('Italiano - Italian'),
'is_is' => $this
->t('íslenska - Icelandic'),
'ja_jp' => $this
->t('日本語 - Japanese'),
'ko_kr' => $this
->t('한국어 - Korean'),
'pt_pt' => $this
->t('Português (Europeu) - Portuguese'),
'nl_nl' => $this
->t('Nederlands - Dutch'),
'nl_be' => $this
->t('Nederlands (Belgisch) - Dutch (Belgian)'),
'no_nb' => $this
->t('Bokmål - Norwegian'),
'no_nn' => $this
->t('Nynorsk - Norwegian'),
'ru_ru' => $this
->t('Русский - Russian'),
'sv_se' => $this
->t('Svenska - Swedish'),
'th_th' => $this
->t('@thai - Thai', [
'@thai' => urldecode('%E0%B9%84%E0%B8%97%E0%B8%A2'),
]),
'tr_tr' => $this
->t('Türkçe - Turkish'),
'zh_cn' => $this
->t('@mandarin - Mandarin Chinese', [
'@mandarin' => urldecode('%E4%B8%AD%E6%96%87%20(%E7%AE%80%E4%BD%93)'),
]),
'zh_hk' => $this
->t('@traditional - Traditional Chinese', [
'@traditional' => urldecode('%E4%B8%AD%E5%9C%8B%EF%BC%88%E7%B9%81%E9%AB%94%EF%BC%89'),
]),
];
$form['settings'] = [
'#title' => $this
->t('General settings for ReadSpeaker'),
'#type' => 'fieldset',
];
$form['settings']['open_readspeaker_accountid'] = [
'#title' => $this
->t('Account ID'),
'#description' => $this
->t('Enter your ReadSpeaker account ID'),
'#type' => 'textfield',
'#default_value' => $config
->get('open_readspeaker_accountid'),
'#required' => TRUE,
];
$form['settings']['open_readspeaker_i18n'] = [
'#title' => $this
->t('Language'),
'#description' => $this
->t('Select which language your ReadSpeaker account supports.'),
'#type' => 'select',
'#options' => $language_options,
'#default_value' => $config
->get('open_readspeaker_i18n'),
'#required' => TRUE,
];
if (\Drupal::moduleHandler()
->moduleExists('token')) {
$form['settings']['token_browser'] = [
'#theme' => 'token_tree_link',
'#token_types' => [
'open_readspeaker',
],
];
$tokenBrowserLink = render($form['settings']['token_browser']);
}
$form['settings']['open_readspeaker_url'] = [
'#title' => $this
->t('URL'),
'#description' => $this
->t('The remote URL of the ReadSpeaker JavaScript.') . ($tokenBrowserLink ?? ''),
'#type' => 'textfield',
'#default_value' => $config
->get('open_readspeaker_url'),
'#required' => TRUE,
];
$form['settings']['open_readspeaker_post_mode'] = [
'#title' => $this
->t('Use POST mode'),
'#description' => $this
->t('Enabling this option will POST the html/text to the ReadSpeaker service instead of ReadSpeaker accessing your site, which will make the service work behind password protected pages.'),
'#type' => 'checkbox',
'#default_value' => $config
->get('open_readspeaker_post_mode'),
];
return parent::buildForm($form, $form_state);
}
/**
* {@inheritdoc}
*/
public function submitForm(array &$form, FormStateInterface $form_state) {
parent::submitForm($form, $form_state);
$this
->config('open_readspeaker.settings')
->set('open_readspeaker_accountid', $form_state
->getValue('open_readspeaker_accountid'))
->set('open_readspeaker_i18n', $form_state
->getValue('open_readspeaker_i18n'))
->set('open_readspeaker_post_mode', $form_state
->getValue('open_readspeaker_post_mode'))
->set('open_readspeaker_url', $form_state
->getValue('open_readspeaker_url'))
->save();
Cache::invalidateTags([
'library_info',
]);
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
ConfigFormBase:: |
public static | function |
Instantiates a new instance of this class. Overrides FormBase:: |
13 |
ConfigFormBase:: |
public | function | Constructs a \Drupal\system\ConfigFormBase object. | 11 |
ConfigFormBaseTrait:: |
protected | function | Retrieves a configuration object. | |
DependencySerializationTrait:: |
protected | property | An array of entity type IDs keyed by the property name of their storages. | |
DependencySerializationTrait:: |
protected | property | An array of service IDs keyed by property name used for serialization. | |
DependencySerializationTrait:: |
public | function | 1 | |
DependencySerializationTrait:: |
public | function | 2 | |
FormBase:: |
protected | property | The config factory. | 1 |
FormBase:: |
protected | property | The request stack. | 1 |
FormBase:: |
protected | property | The route match. | |
FormBase:: |
protected | function | Gets the config factory for this form. | 1 |
FormBase:: |
private | function | Returns the service container. | |
FormBase:: |
protected | function | Gets the current user. | |
FormBase:: |
protected | function | Gets the request object. | |
FormBase:: |
protected | function | Gets the route match. | |
FormBase:: |
protected | function | Gets the logger for a specific channel. | |
FormBase:: |
protected | function |
Returns a redirect response object for the specified route. Overrides UrlGeneratorTrait:: |
|
FormBase:: |
public | function | Resets the configuration factory. | |
FormBase:: |
public | function | Sets the config factory for this form. | |
FormBase:: |
public | function | Sets the request stack object to use. | |
FormBase:: |
public | function |
Form validation handler. Overrides FormInterface:: |
62 |
LinkGeneratorTrait:: |
protected | property | The link generator. | 1 |
LinkGeneratorTrait:: |
protected | function | Returns the link generator. | |
LinkGeneratorTrait:: |
protected | function | Renders a link to a route given a route name and its parameters. | |
LinkGeneratorTrait:: |
public | function | Sets the link generator service. | |
LoggerChannelTrait:: |
protected | property | The logger channel factory service. | |
LoggerChannelTrait:: |
protected | function | Gets the logger for a specific channel. | |
LoggerChannelTrait:: |
public | function | Injects the logger channel factory. | |
MessengerTrait:: |
protected | property | The messenger. | 29 |
MessengerTrait:: |
public | function | Gets the messenger. | 29 |
MessengerTrait:: |
public | function | Sets the messenger. | |
OpenReadSpeakerSettingsForm:: |
public | function |
Form constructor. Overrides ConfigFormBase:: |
|
OpenReadSpeakerSettingsForm:: |
protected | function |
Gets the configuration names that will be editable. Overrides ConfigFormBaseTrait:: |
|
OpenReadSpeakerSettingsForm:: |
public | function |
Returns a unique string identifying the form. Overrides FormInterface:: |
|
OpenReadSpeakerSettingsForm:: |
public | function |
Form submission handler. Overrides ConfigFormBase:: |
|
RedirectDestinationTrait:: |
protected | property | The redirect destination service. | 1 |
RedirectDestinationTrait:: |
protected | function | Prepares a 'destination' URL query parameter for use with \Drupal\Core\Url. | |
RedirectDestinationTrait:: |
protected | function | Returns the redirect destination service. | |
RedirectDestinationTrait:: |
public | function | Sets the redirect destination service. | |
StringTranslationTrait:: |
protected | property | The string translation service. | 1 |
StringTranslationTrait:: |
protected | function | Formats a string containing a count of items. | |
StringTranslationTrait:: |
protected | function | Returns the number of plurals supported by a given language. | |
StringTranslationTrait:: |
protected | function | Gets the string translation service. | |
StringTranslationTrait:: |
public | function | Sets the string translation service to use. | 2 |
StringTranslationTrait:: |
protected | function | Translates a string to the current language or to a given language. | |
UrlGeneratorTrait:: |
protected | property | The url generator. | |
UrlGeneratorTrait:: |
protected | function | Returns the URL generator service. | |
UrlGeneratorTrait:: |
public | function | Sets the URL generator service. | |
UrlGeneratorTrait:: |
protected | function | Generates a URL or path for a specific route based on the given parameters. |