plugin = $plugin; $this->newSettings = $newSettings; } public function getSetting($settingName) { $value = null; if (null !== $this->newSettings) { if (isset($this->newSettings[$settingName])) { $value = $this->newSettings[$settingName]; } if (empty($value)) { $prefix = $this->plugin->getPluginName(); if (substr($settingName, 0, strlen($prefix)) == $prefix) { $settingNameWithoutPrefix = substr($settingName, strlen($prefix) + 1); } if (isset($this->newSettings[$settingNameWithoutPrefix])) { $value = $this->newSettings[$settingNameWithoutPrefix]; } } if ($this->isSettingUrl($value)) { $value = $this->processUrl($value); } if (!empty($value)) { return $value; } } switch ($settingName) { case $this->jwtHeader: $value = api_get_setting($settingName)[$this->plugin->getPluginName()]; if (empty($value)) { $value = 'Authorization'; } break; case $this->documentServerInternalUrl: $value = api_get_setting($settingName)[$this->plugin->getPluginName()]; break; case $this->useDemoName: $value = api_get_setting($settingName)[0]; break; case $this->jwtPrefix: $value = 'Bearer '; break; default: if (!empty($this->plugin) && method_exists($this->plugin, 'get')) { $value = $this->plugin->get($settingName); } } if (empty($value)) { $value = api_get_configuration_value($settingName); } return $value; } public function setSetting($settingName, $value, $createSetting = false) { if (($settingName === $this->useDemoName) && $createSetting) { api_add_setting($value, $settingName, null, 'setting', 'Plugins'); return; } $prefix = $this->plugin->getPluginName(); if (!(substr($settingName, 0, strlen($prefix)) == $prefix)) { $settingName = $prefix.'_'.$settingName; } api_set_setting($settingName, $value); } public function getServerUrl() { return api_get_path(WEB_PATH); } /** * Get link to Docs Cloud. * * @return string */ public function getLinkToDocs() { return self::LINK_TO_DOCS; } public function isSettingUrl($settingName) { return in_array($settingName, [$this->documentServerUrl, $this->documentServerInternalUrl, $this->storageUrl]); } }