diff options
author | Thomas Steur <thomas.steur@gmail.com> | 2015-06-02 04:09:15 +0300 |
---|---|---|
committer | Thomas Steur <thomas.steur@gmail.com> | 2015-06-17 08:09:13 +0300 |
commit | 18501381cec766aa729fdc7bdcd282c90a7be45f (patch) | |
tree | cf7cfe213d72cbd57ec86e570a5e2a7c4dc55815 /core/Settings | |
parent | 1f707dd3c9422494b7cf844591079c11c651158c (diff) |
refs #7893 added possibility to measure mobile apps
Diffstat (limited to 'core/Settings')
-rw-r--r-- | core/Settings/Setting.php | 17 | ||||
-rw-r--r-- | core/Settings/Storage.php | 9 |
2 files changed, 18 insertions, 8 deletions
diff --git a/core/Settings/Setting.php b/core/Settings/Setting.php index 51e7942146..bf8947b196 100644 --- a/core/Settings/Setting.php +++ b/core/Settings/Setting.php @@ -153,7 +153,7 @@ abstract class Setting * @var StorageInterface */ private $storage; - private $pluginName; + protected $pluginName; /** * Constructor. @@ -266,11 +266,7 @@ abstract class Setting */ public function setValue($value) { - $this->checkHasEnoughWritePermission(); - - if ($this->validate && $this->validate instanceof \Closure) { - call_user_func($this->validate, $value, $this); - } + $this->validateValue($value); if ($this->transform && $this->transform instanceof \Closure) { $value = call_user_func($this->transform, $value, $this); @@ -281,6 +277,15 @@ abstract class Setting return $this->storage->setValue($this, $value); } + private function validateValue($value) + { + $this->checkHasEnoughWritePermission(); + + if ($this->validate && $this->validate instanceof \Closure) { + call_user_func($this->validate, $value, $this); + } + } + /** * @throws \Exception */ diff --git a/core/Settings/Storage.php b/core/Settings/Storage.php index 5e3b8fc793..131c01b111 100644 --- a/core/Settings/Storage.php +++ b/core/Settings/Storage.php @@ -24,7 +24,7 @@ class Storage implements StorageInterface * * @var array */ - private $settingsValues = array(); + protected $settingsValues = array(); // for lazy loading of setting values private $settingValuesLoaded = false; @@ -52,12 +52,17 @@ class Storage implements StorageInterface */ public function deleteAllValues() { - Option::delete($this->getOptionKey()); + $this->deleteSettingsFromStorage(); $this->settingsValues = array(); $this->settingValuesLoaded = false; } + protected function deleteSettingsFromStorage() + { + Option::delete($this->getOptionKey()); + } + /** * Returns the current value for a setting. If no value is stored, the default value * is be returned. |