Skip to content

Commit

Permalink
Merge pull request #2 from ueberbit/default-config
Browse files Browse the repository at this point in the history
#1 Added default config and completed config ui.
  • Loading branch information
zuernBernhard authored Nov 11, 2016
2 parents c55ca64 + 9a2862e commit c476025
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 0 deletions.
2 changes: 2 additions & 0 deletions config/install/shariff_backend.settings.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
cache_ttl: '0'
simulate_counts: 0
6 changes: 6 additions & 0 deletions config/schema/shariff_backend.settings.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,9 @@ shariff_backend.settings:
facebook_app_secret:
type: string
label: 'Facebook application client secret'
base_domain:
type: string
label: 'Base domain of production instance'
simulate_counts:
type: boolean
label: 'Indicate if the counts should be simulated.'
1 change: 1 addition & 0 deletions shariff_backend.info.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,4 @@ type: module
description: Integration of the Shariff backend.
core: 8.x
package: Web services
configure: shariff_backend.settings
18 changes: 18 additions & 0 deletions src/Form/ShariffBackendSettingsForm.php
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,22 @@ public function buildForm(array $form, FormStateInterface $form_state) {
'#description' => $this->t('An optional client secret needed to access the Facebook application(required if Facebook application ID is set).'),
);

// Base Domain
$form['base_domain'] = array(
'#type' => 'textfield',
'#title' => $this->t('Base domain to check against.'),
'#default_value' => $config->get('base_domain'),
'#description' => $this->t('Can be the live domain for testing on a development machine.'),
);

// Simulate Counts
$form['simulate_counts'] = array(
'#type' => 'checkbox',
'#title' => $this->t('Simuate counts'),
'#default_value' => $config->get('simulate_counts'),
'#description' => $this->t('Simulate fictional counts.'),
);

// Share count cache TTL
$options = [3600, 10800, 21600, 43200, 86400, 604800];
$form['cache_ttl'] = [
Expand All @@ -73,6 +89,8 @@ public function submitForm(array &$form, FormStateInterface $form_state) {
->set('cache_ttl', $form_state->getValue('cache_ttl'))
->set('facebook_app_id', $form_state->getValue('facebook_app_id'))
->set('facebook_app_secret', $form_state->getValue('facebook_app_secret'))
->set('base_domain', $form_state->getValue('base_domain'))
->set('simulate_counts', $form_state->getValue('simulate_counts'))
->save();

parent::submitForm($form, $form_state);
Expand Down

0 comments on commit c476025

Please sign in to comment.