-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add configuration settings to enable or disable resolvers
- Loading branch information
Showing
24 changed files
with
593 additions
and
21 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
# Upgrade guide | ||
|
||
## Upgrade from 2.0.1 to 2.1.x | ||
|
||
This guide is intended to describe the process of upgrading | ||
Times'up from version 2.0.1 to version 2.1.x. | ||
|
||
### Changes in configuration | ||
|
||
Running `drush updb` and exporting the changed configuration should be sufficient | ||
to convert to the new configuration structure. | ||
|
||
The `timesup.settings` configuration object has been introduced. This allows you to enable only the resolvers you actively use, reducing stress on cache and database invalidation. | ||
|
||
```yaml | ||
resolvers: | ||
minutely: false | ||
hourly: true | ||
daily: true | ||
midnight: true | ||
weekly: true | ||
``` | ||
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
resolvers: | ||
minutely: false | ||
hourly: true | ||
daily: true | ||
midnight: true | ||
weekly: true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
timesup.settings: | ||
type: config_object | ||
label: Times'up settings | ||
mapping: | ||
resolvers: | ||
type: mapping | ||
label: 'Resolvers' | ||
mapping: | ||
minutely: | ||
type: boolean | ||
label: Enable minutely's Times'up cache resolvers | ||
hourly: | ||
type: boolean | ||
label: Enable daily's Times'up cache resolvers | ||
daily: | ||
type: boolean | ||
label: Enable daily's Times'up cache resolvers | ||
midnight: | ||
type: boolean | ||
label: Enable midnight's Times'up cache resolvers | ||
weekly: | ||
type: boolean | ||
label: Enable weekly's Times'up cache resolvers |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,100 @@ | ||
<?php | ||
|
||
namespace Drupal\timesup\Form; | ||
|
||
use Drupal\Core\Form\ConfigFormBase; | ||
use Drupal\Core\Form\FormStateInterface; | ||
|
||
/** | ||
* Times'up settings form. | ||
*/ | ||
class SettingsForm extends ConfigFormBase { | ||
|
||
/** | ||
* {@inheritdoc} | ||
*/ | ||
public function getFormId() { | ||
return 'timesup_admin_settings'; | ||
} | ||
|
||
/** | ||
* {@inheritdoc} | ||
*/ | ||
public function buildForm(array $form, FormStateInterface $form_state) { | ||
$form = parent::buildForm($form, $form_state); | ||
$resolvers = $this->config('timesup.settings')->get('resolvers'); | ||
|
||
// Submitted form values should be nested. | ||
$form['#tree'] = TRUE; | ||
|
||
$form['resolvers'] = [ | ||
'#type' => 'fieldset', | ||
'#title' => $this->t('Resolvers'), | ||
'#description' => $this->t('Please enable resolvers you actively use to avoid cache/database invalidation stress.'), | ||
]; | ||
|
||
$form['resolvers']['minutely'] = [ | ||
'#type' => 'checkbox', | ||
'#title' => $this->t('Enable Minutely resolver.'), | ||
'#default_value' => !empty($resolvers['minutely']), | ||
'#description' => $this->t('Enable this feature will invalid cache-tags <code>timesup:minutely</code> every minutes (heavy stress sensitive).'), | ||
]; | ||
|
||
$form['resolvers']['hourly'] = [ | ||
'#type' => 'checkbox', | ||
'#title' => $this->t('Enable Hourly resolver.'), | ||
'#default_value' => !empty($resolvers['hourly']), | ||
'#description' => $this->t('Enable this feature will invalid cache-tags <code>timesup:hourly</code> every hour.'), | ||
]; | ||
|
||
$form['resolvers']['daily'] = [ | ||
'#type' => 'checkbox', | ||
'#title' => $this->t('Enable Daily resolver.'), | ||
'#default_value' => !empty($resolvers['daily']), | ||
'#description' => $this->t('Enable this feature will invalid cache-tags <code>timesup:daily</code> every day.'), | ||
]; | ||
|
||
$form['resolvers']['midnight'] = [ | ||
'#type' => 'checkbox', | ||
'#title' => $this->t('Enable Midnight resolver.'), | ||
'#default_value' => !empty($resolvers['midnight']), | ||
'#description' => $this->t('Enable this feature will invalid cache-tags <code>timesup:midnight</code> every day at 00:00:00.'), | ||
]; | ||
|
||
$form['resolvers']['weekly'] = [ | ||
'#type' => 'checkbox', | ||
'#title' => $this->t('Enable Weekly resolver.'), | ||
'#default_value' => !empty($resolvers['weekly']), | ||
'#description' => $this->t('Enable this feature will invalid cache-tags <code>timesup:weekly</code> every weeks.'), | ||
]; | ||
|
||
return $form; | ||
} | ||
|
||
/** | ||
* {@inheritdoc} | ||
*/ | ||
public function submitForm(array &$form, FormStateInterface $form_state) { | ||
parent::submitForm($form, $form_state); | ||
|
||
$this->config('timesup.settings') | ||
->set('resolvers', [ | ||
'minutely' => (bool) $form_state->getValue(['resolvers', 'minutely']), | ||
'hourly' => (bool) $form_state->getValue(['resolvers', 'hourly']), | ||
'daily' => (bool) $form_state->getValue(['resolvers', 'daily']), | ||
'midnight' => (bool) $form_state->getValue(['resolvers', 'midnight']), | ||
'weekly' => (bool) $form_state->getValue(['resolvers', 'weekly']), | ||
]) | ||
->save(); | ||
} | ||
|
||
/** | ||
* {@inheritdoc} | ||
*/ | ||
protected function getEditableConfigNames() { | ||
return [ | ||
'timesup.settings', | ||
]; | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.