class AddthisSettingsForm in Share Message 8
Defines a form that configures Share Message settings.
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\sharemessage\Form\AddthisSettingsForm
- class \Drupal\Core\Form\ConfigFormBase uses ConfigFormBaseTrait
Expanded class hierarchy of AddthisSettingsForm
1 string reference to 'AddthisSettingsForm'
File
- src/
Form/ AddthisSettingsForm.php, line 13
Namespace
Drupal\sharemessage\FormView source
class AddthisSettingsForm extends ConfigFormBase {
/**
* {@inheritdoc}
*/
protected function getEditableConfigNames() {
return [
'sharemessage.addthis',
];
}
/**
* {@inheritdoc}
*/
public function getFormID() {
return 'sharemessage_addthis_settings';
}
/**
* {@inheritdoc}
*/
public function buildForm(array $form, FormStateInterface $form_state, Request $request = NULL) {
$config = $this
->config('sharemessage.addthis');
// AddThis specific settings.
$form['addthis_profile_id'] = [
'#title' => t('AddThis Profile ID'),
'#type' => 'textfield',
'#default_value' => $config
->get('addthis_profile_id'),
];
$form['default_services'] = [
'#title' => t('Default visible services'),
'#type' => 'select',
'#multiple' => TRUE,
'#options' => sharemessage_get_addthis_services(),
'#default_value' => $config
->get('services'),
'#size' => 10,
];
$form['default_additional_services'] = [
'#type' => 'checkbox',
'#title' => t('Show additional services button'),
'#default_value' => $config
->get('additional_services'),
];
$form['default_counter'] = [
'#type' => 'select',
'#title' => t('Show AddThis counter'),
'#empty_option' => t('No'),
'#options' => [
'addthis_pill_style' => t('Pill style'),
'addthis_bubble_style' => t('Bubble style'),
],
'#default_value' => $config
->get('counter'),
];
$form['default_icon_style'] = [
'#title' => t('Default icon style'),
'#type' => 'radios',
'#options' => [
'addthis_16x16_style' => '16x16 pix',
'addthis_32x32_style' => '32x32 pix',
],
'#default_value' => $config
->get('icon_style'),
];
$form['local_services_definition'] = [
'#type' => 'checkbox',
'#title' => t('Use local service definitions file'),
'#description' => t('Check this if you are behind a firewall and the module cannot access the services definition at http://cache.addthiscdn.com/services/v1/sharing.en.json.'),
'#default_value' => $config
->get('local_services_definition'),
];
$form['shared_video_width'] = [
'#title' => t('Video height'),
'#description' => t('The width of the player when sharing a video.'),
'#type' => 'textfield',
'#default_value' => $config
->get('shared_video_width'),
];
$form['shared_video_height'] = [
'#title' => t('Video height'),
'#description' => t('The height of the player when sharing a video.'),
'#type' => 'textfield',
'#default_value' => $config
->get('shared_video_height'),
];
return parent::buildForm($form, $form_state);
}
/**
* {@inheritdoc}
*/
public function submitForm(array &$form, FormStateInterface $form_state) {
parent::submitForm($form, $form_state);
// If the profile id changes then we need to rebuild the library cache.
Cache::invalidateTags([
'library_info',
]);
$this
->config('sharemessage.addthis')
->set('addthis_profile_id', $form_state
->getValue('addthis_profile_id'))
->set('services', $form_state
->getValue('default_services'))
->set('additional_services', $form_state
->getValue('default_additional_services'))
->set('counter', $form_state
->getValue('default_counter'))
->set('icon_style', $form_state
->getValue('default_icon_style'))
->set('local_services_definition', $form_state
->getValue('local_services_definition'))
->set('shared_video_width', $form_state
->getValue('shared_video_width'))
->set('shared_video_height', $form_state
->getValue('shared_video_height'))
->save();
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
AddthisSettingsForm:: |
public | function |
Form constructor. Overrides ConfigFormBase:: |
|
AddthisSettingsForm:: |
protected | function |
Gets the configuration names that will be editable. Overrides ConfigFormBaseTrait:: |
|
AddthisSettingsForm:: |
public | function | ||
AddthisSettingsForm:: |
public | function |
Form submission handler. Overrides ConfigFormBase:: |
|
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 |
FormInterface:: |
public | function | Returns a unique string identifying the form. | 236 |
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. | |
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. |