systemconfig.php 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. <?php
  2. /**
  3. * @author Joas Schilling <nickvergessen@owncloud.com>
  4. * @author Morris Jobke <hey@morrisjobke.de>
  5. *
  6. * @copyright Copyright (c) 2015, ownCloud, Inc.
  7. * @license AGPL-3.0
  8. *
  9. * This code is free software: you can redistribute it and/or modify
  10. * it under the terms of the GNU Affero General Public License, version 3,
  11. * as published by the Free Software Foundation.
  12. *
  13. * This program is distributed in the hope that it will be useful,
  14. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  15. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  16. * GNU Affero General Public License for more details.
  17. *
  18. * You should have received a copy of the GNU Affero General Public License, version 3,
  19. * along with this program. If not, see <http://www.gnu.org/licenses/>
  20. *
  21. */
  22. namespace OC;
  23. /**
  24. * Class which provides access to the system config values stored in config.php
  25. * Internal class for bootstrap only.
  26. * fixes cyclic DI: AllConfig needs AppConfig needs Database needs AllConfig
  27. */
  28. class SystemConfig {
  29. /**
  30. * Lists all available config keys
  31. * @return array an array of key names
  32. */
  33. public function getKeys() {
  34. return \OC_Config::getKeys();
  35. }
  36. /**
  37. * Sets a new system wide value
  38. *
  39. * @param string $key the key of the value, under which will be saved
  40. * @param mixed $value the value that should be stored
  41. */
  42. public function setValue($key, $value) {
  43. \OC_Config::setValue($key, $value);
  44. }
  45. /**
  46. * Sets and deletes values and writes the config.php
  47. *
  48. * @param array $configs Associative array with `key => value` pairs
  49. * If value is null, the config key will be deleted
  50. */
  51. public function setValues(array $configs) {
  52. \OC_Config::setValues($configs);
  53. }
  54. /**
  55. * Looks up a system wide defined value
  56. *
  57. * @param string $key the key of the value, under which it was saved
  58. * @param mixed $default the default value to be returned if the value isn't set
  59. * @return mixed the value or $default
  60. */
  61. public function getValue($key, $default = '') {
  62. return \OC_Config::getValue($key, $default);
  63. }
  64. /**
  65. * Delete a system wide defined value
  66. *
  67. * @param string $key the key of the value, under which it was saved
  68. */
  69. public function deleteValue($key) {
  70. \OC_Config::deleteKey($key);
  71. }
  72. }