public function TwitterButtonFormatter::getSettings in Twitter Embed 8
Returns the array of settings, including defaults for missing settings.
Return value
array The array of settings.
Overrides PluginSettingsBase::getSettings
File
- src/
Plugin/ Field/ FieldFormatter/ TwitterButtonFormatter.php, line 41
Class
- TwitterButtonFormatter
- Plugin implementation of the 'twitter_button_formatter' formatter.
Namespace
Drupal\twitter_embed\Plugin\Field\FieldFormatterCode
public function getSettings() {
// Override settings so in case of format change, the settings
// that differ between formatters are not overridden.
// If a setting value is not from the same set,
// pick the default value.
// @todo refactoring needed to generalize:
// - to other settings differences
// - with getSetting(key)
// - with setDependentConfiguration() method.
// @todo settings that are enclosed in a fieldset (display options) are not saved.
if (!array_key_exists($this
->getSetting('type'), $this->twitterWidget
->getAvailableTypes())) {
// Type does not exist for Button widget.
$type = '';
$this
->setSetting('type', $type);
}
if (!array_key_exists($this
->getSetting('display_style'), $this->twitterWidget
->getAvailableDisplayStyles())) {
$displayStyle = TwitterButtonWidget::getDefaultSettings()['display_style'];
$this
->setSetting('display_style', $displayStyle);
}
return parent::getSettings();
}