示例#1
0
 /**
  * Sets and persists this setting's value overwriting any existing value.
  *
  * @param mixed $value
  * @throws \Exception If the current user is not allowed to change the value of this setting.
  */
 public function setValue($value)
 {
     $this->checkHasEnoughWritePermission();
     if ($this->validate && $this->validate instanceof \Closure) {
         call_user_func($this->validate, $value, $this);
     }
     if ($this->transform && $this->transform instanceof \Closure) {
         $value = call_user_func($this->transform, $value, $this);
     } elseif (isset($this->type)) {
         settype($value, $this->type);
     }
     return $this->storage->setValue($this, $value);
 }
示例#2
0
 /**
  * Removes all settings for this plugin from the database. Useful when uninstalling
  * a plugin.
  */
 public function removeAllPluginSettings()
 {
     Piwik::checkUserHasSuperUserAccess();
     $this->storage->deleteAllValues();
     SettingsStorage::clearCache();
 }
示例#3
0
 /**
  * Sets and persists this setting's value overwriting any existing value.
  *
  * @param mixed $value
  * @throws \Exception If the current user is not allowed to change the value of this setting.
  */
 public function setValue($value)
 {
     $this->validateValue($value);
     if ($this->transform && $this->transform instanceof \Closure) {
         $value = call_user_func($this->transform, $value, $this);
     } elseif (isset($this->type)) {
         settype($value, $this->type);
     }
     return $this->storage->setValue($this, $value);
 }