IDeclarativeManager.php 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. <?php
  2. declare(strict_types=1);
  3. /**
  4. * SPDX-FileCopyrightText: 2023 Nextcloud GmbH and Nextcloud contributors
  5. * SPDX-License-Identifier: AGPL-3.0-or-later
  6. */
  7. namespace OCP\Settings;
  8. use Exception;
  9. use OC\AppFramework\Middleware\Security\Exceptions\NotAdminException;
  10. use OCP\IUser;
  11. /**
  12. * @since 29.0.0
  13. *
  14. * @psalm-import-type DeclarativeSettingsValueTypes from IDeclarativeSettingsForm
  15. * @psalm-import-type DeclarativeSettingsSectionType from IDeclarativeSettingsForm
  16. * @psalm-import-type DeclarativeSettingsFormSchemaWithValues from IDeclarativeSettingsForm
  17. * @psalm-import-type DeclarativeSettingsFormSchemaWithoutValues from IDeclarativeSettingsForm
  18. */
  19. interface IDeclarativeManager {
  20. /**
  21. * Registers a new declarative settings schema.
  22. *
  23. * @param DeclarativeSettingsFormSchemaWithoutValues $schema
  24. * @since 29.0.0
  25. */
  26. public function registerSchema(string $app, array $schema): void;
  27. /**
  28. * Load all schemas from the registration context and events.
  29. *
  30. * @since 29.0.0
  31. */
  32. public function loadSchemas(): void;
  33. /**
  34. * Gets the IDs of the forms for the given type and section.
  35. *
  36. * @param DeclarativeSettingsSectionType $type
  37. * @param string $section
  38. * @return array<string, list<string>>
  39. *
  40. * @since 29.0.0
  41. */
  42. public function getFormIDs(IUser $user, string $type, string $section): array;
  43. /**
  44. * Gets the forms including the field values for the given type and section.
  45. *
  46. * @param IUser $user Used for reading values from the personal section or for authorization for the admin section.
  47. * @param ?DeclarativeSettingsSectionType $type If it is null the forms will not be filtered by type.
  48. * @param ?string $section If it is null the forms will not be filtered by section.
  49. * @return list<DeclarativeSettingsFormSchemaWithValues>
  50. *
  51. * @since 29.0.0
  52. */
  53. public function getFormsWithValues(IUser $user, ?string $type, ?string $section): array;
  54. /**
  55. * Sets a value for the given field ID.
  56. *
  57. * @param IUser $user Used for storing values in the personal section or for authorization for the admin section.
  58. * @param DeclarativeSettingsValueTypes $value
  59. *
  60. * @throws Exception
  61. * @throws NotAdminException
  62. *
  63. * @since 29.0.0
  64. */
  65. public function setValue(IUser $user, string $app, string $formId, string $fieldId, mixed $value): void;
  66. }