public function TwitterTimelineFormatter::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/ TwitterTimelineFormatter.php, line 41
Class
- TwitterTimelineFormatter
- Plugin implementation of the 'twitter_timeline_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 = TwitterTimelineWidget::getDefaultSettings()['type'];
$this
->setSetting('type', $type);
}
if (!array_key_exists($this
->getSetting('display_style'), $this->twitterWidget
->getAvailableDisplayStyles())) {
$displayStyle = TwitterTimelineWidget::getDefaultSettings()['display_style'];
$this
->setSetting('display_style', $displayStyle);
}
return parent::getSettings();
}