You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

IDeclarativeManager.php 2.9KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  1. <?php
  2. /**
  3. * @copyright Copyright (c) 2023 Kate Döen <kate.doeen@nextcloud.com>
  4. *
  5. * @author Kate Döen <kate.doeen@nextcloud.com>
  6. *
  7. * @license GNU AGPL version 3 or any later version
  8. *
  9. * This program is free software: you can redistribute it and/or modify
  10. * it under the terms of the GNU Affero General Public License as
  11. * published by the Free Software Foundation, either version 3 of the
  12. * License, or (at your option) any later version.
  13. *
  14. * This program is distributed in the hope that it will be useful,
  15. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  16. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  17. * GNU Affero General Public License for more details.
  18. *
  19. * You should have received a copy of the GNU Affero General Public License
  20. * along with this program. If not, see <http://www.gnu.org/licenses/>.
  21. *
  22. */
  23. namespace OCP\Settings;
  24. use Exception;
  25. use OC\AppFramework\Middleware\Security\Exceptions\NotAdminException;
  26. use OCP\IUser;
  27. /**
  28. * @since 29.0.0
  29. *
  30. * @psalm-import-type DeclarativeSettingsValueTypes from IDeclarativeSettingsForm
  31. * @psalm-import-type DeclarativeSettingsSectionType from IDeclarativeSettingsForm
  32. * @psalm-import-type DeclarativeSettingsFormSchemaWithValues from IDeclarativeSettingsForm
  33. * @psalm-import-type DeclarativeSettingsFormSchemaWithoutValues from IDeclarativeSettingsForm
  34. */
  35. interface IDeclarativeManager {
  36. /**
  37. * Registers a new declarative settings schema.
  38. *
  39. * @param DeclarativeSettingsFormSchemaWithoutValues $schema
  40. * @since 29.0.0
  41. */
  42. public function registerSchema(string $app, array $schema): void;
  43. /**
  44. * Load all schemas from the registration context and events.
  45. *
  46. * @since 29.0.0
  47. */
  48. public function loadSchemas(): void;
  49. /**
  50. * Gets the IDs of the forms for the given type and section.
  51. *
  52. * @param DeclarativeSettingsSectionType $type
  53. * @param string $section
  54. * @return array<string, list<string>>
  55. *
  56. * @since 29.0.0
  57. */
  58. public function getFormIDs(IUser $user, string $type, string $section): array;
  59. /**
  60. * Gets the forms including the field values for the given type and section.
  61. *
  62. * @param IUser $user Used for reading values from the personal section or for authorization for the admin section.
  63. * @param ?DeclarativeSettingsSectionType $type If it is null the forms will not be filtered by type.
  64. * @param ?string $section If it is null the forms will not be filtered by section.
  65. * @return list<DeclarativeSettingsFormSchemaWithValues>
  66. *
  67. * @since 29.0.0
  68. */
  69. public function getFormsWithValues(IUser $user, ?string $type, ?string $section): array;
  70. /**
  71. * Sets a value for the given field ID.
  72. *
  73. * @param IUser $user Used for storing values in the personal section or for authorization for the admin section.
  74. * @param DeclarativeSettingsValueTypes $value
  75. *
  76. * @throws Exception
  77. * @throws NotAdminException
  78. *
  79. * @since 29.0.0
  80. */
  81. public function setValue(IUser $user, string $app, string $formId, string $fieldId, mixed $value): void;
  82. }