function _shariff_get_settings in Shariff Social Media Buttons 8
Same name and namespace in other branches
- 7 shariff.module \_shariff_get_settings()
Helper function to get the module settings.
3 calls to _shariff_get_settings()
- ShariffSettingsForm::buildForm in src/
Form/ ShariffSettingsForm.php - Form constructor.
- shariff_node_view in ./
shariff.module - Implements hook_ENTITY_TYPE_view().
- shariff_preprocess_block_shariff in ./
shariff.module - Implements hook_preprocess().
File
- ./
shariff.module, line 139 - Integrating Shariff library, providing settings form and block.
Code
function _shariff_get_settings($blocksettings = NULL) {
$language = \Drupal::languageManager()
->getCurrentLanguage();
$lang = $language
->getId();
$supported_languages = _shariff_supported_languages();
if ($blocksettings && !$blocksettings['shariff_default_settings']) {
// block specific settings are active.
$services = $blocksettings['shariff_services'];
$setting['shariff_theme'] = $blocksettings['shariff_theme'];
foreach ($blocksettings as $setting => $value) {
if ($setting != 'shariff_service' || $setting != 'shariff_theme') {
$attribute = str_replace('shariff_', '', $setting);
$settings[$attribute] = $blocksettings[$setting];
}
}
}
else {
// Use default settings form values.
$services = \Drupal::config('shariff.settings')
->get('shariff_services');
$settings = [
'services' => $services,
'shariff_theme' => \Drupal::config('shariff.settings')
->get('shariff_theme'),
'css' => \Drupal::config('shariff.settings')
->get('shariff_css'),
'orientation' => \Drupal::config('shariff.settings')
->get('shariff_orientation'),
'twitter_via' => \Drupal::config('shariff.settings')
->get('shariff_twitter_via'),
'mail_url' => \Drupal::config('shariff.settings')
->get('shariff_mail_url'),
'mail_subject' => \Drupal::config('shariff.settings')
->get('shariff_mail_subject'),
'mail_body' => \Drupal::config('shariff.settings')
->get('shariff_mail_body'),
'referrer_track' => \Drupal::config('shariff.settings')
->get('shariff_referrer_track'),
'backend_url' => \Drupal::config('shariff.settings')
->get('shariff_backend_url'),
'flattr_category' => \Drupal::config('shariff.settings')
->get('shariff_flattr_category'),
'flattr_user' => \Drupal::config('shariff.settings')
->get('shariff_flattr_user'),
'media_url' => \Drupal::config('shariff.settings')
->get('shariff_media_url'),
'button_style' => \Drupal::config('shariff.settings')
->get('shariff_button_style'),
'info_url' => \Drupal::config('shariff.settings')
->get('shariff_info_url'),
'info_display' => \Drupal::config('shariff.settings')
->get('shariff_info_display'),
'title' => \Drupal::config('shariff.settings')
->get('shariff_title'),
'url' => \Drupal::config('shariff.settings')
->get('shariff_url'),
];
}
foreach ($services as $key => $service) {
$services[$key] = Html::escape($service);
if (!$service) {
unset($services[$key]);
}
}
$settings['services'] = $services;
$settings['lang'] = in_array($lang, $supported_languages) ? $lang : 'en';
return $settings;
}