IAppConfig.php 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111
  1. <?php
  2. declare(strict_types=1);
  3. /**
  4. * @copyright Copyright (c) 2020, Roeland Jago Douma <roeland@famdouma.nl>
  5. *
  6. * @author Roeland Jago Douma <roeland@famdouma.nl>
  7. *
  8. * @license GNU AGPL version 3 or any later version
  9. *
  10. * This program is free software: you can redistribute it and/or modify
  11. * it under the terms of the GNU Affero General Public License as
  12. * published by the Free Software Foundation, either version 3 of the
  13. * License, or (at your option) any later version.
  14. *
  15. * This program is distributed in the hope that it will be useful,
  16. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  17. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  18. * GNU Affero General Public License for more details.
  19. *
  20. * You should have received a copy of the GNU Affero General Public License
  21. * along with this program. If not, see <http://www.gnu.org/licenses/>.
  22. *
  23. */
  24. namespace OCP\AppFramework\Services;
  25. /**
  26. * Wrapper for AppConfig for the AppFramework
  27. *
  28. * @since 20.0.0
  29. */
  30. interface IAppConfig {
  31. /**
  32. * Get all keys stored for this app
  33. *
  34. * @return string[] the keys stored for the app
  35. * @since 20.0.0
  36. */
  37. public function getAppKeys(): array ;
  38. /**
  39. * Writes a new app wide value
  40. *
  41. * @param string $key the key of the value, under which will be saved
  42. * @param string $value the value that should be stored
  43. * @return void
  44. * @since 20.0.0
  45. */
  46. public function setAppValue(string $key, string $value): void;
  47. /**
  48. * Looks up an app wide defined value
  49. *
  50. * @param string $key the key of the value, under which it was saved
  51. * @param string $default the default value to be returned if the value isn't set
  52. * @return string the saved value
  53. * @since 20.0.0
  54. */
  55. public function getAppValue(string $key, string $default = ''): string;
  56. /**
  57. * Delete an app wide defined value
  58. *
  59. * @param string $key the key of the value, under which it was saved
  60. * @return void
  61. * @since 20.0.0
  62. */
  63. public function deleteAppValue(string $key): void;
  64. /**
  65. * Removes all keys in appconfig belonging to the app
  66. *
  67. * @return void
  68. * @since 20.0.0
  69. */
  70. public function deleteAppValues(): void;
  71. /**
  72. * Set a user defined value
  73. *
  74. * @param string $userId the userId of the user that we want to store the value under
  75. * @param string $key the key under which the value is being stored
  76. * @param string $value the value that you want to store
  77. * @param string $preCondition only update if the config value was previously the value passed as $preCondition
  78. * @throws \OCP\PreConditionNotMetException if a precondition is specified and is not met
  79. * @throws \UnexpectedValueException when trying to store an unexpected value
  80. * @since 20.0.0
  81. */
  82. public function setUserValue(string $userId, string $key, string $value, ?string $preCondition = null): void;
  83. /**
  84. * Shortcut for getting a user defined value
  85. *
  86. * @param string $userId the userId of the user that we want to store the value under
  87. * @param string $key the key under which the value is being stored
  88. * @param mixed $default the default value to be returned if the value isn't set
  89. * @return string
  90. * @since 20.0.0
  91. */
  92. public function getUserValue(string $userId, string $key, string $default = ''): string;
  93. /**
  94. * Delete a user value
  95. *
  96. * @param string $userId the userId of the user that we want to store the value under
  97. * @param string $key the key under which the value is being stored
  98. * @since 20.0.0
  99. */
  100. public function deleteUserValue(string $userId, string $key): void;
  101. }