1
0

IDeclarativeManager.php 3.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  1. <?php
  2. declare(strict_types=1);
  3. /**
  4. * @copyright Copyright (c) 2023 Kate Döen <kate.doeen@nextcloud.com>
  5. *
  6. * @author Kate Döen <kate.doeen@nextcloud.com>
  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\Settings;
  25. use Exception;
  26. use OC\AppFramework\Middleware\Security\Exceptions\NotAdminException;
  27. use OCP\IUser;
  28. /**
  29. * @since 29.0.0
  30. *
  31. * @psalm-import-type DeclarativeSettingsValueTypes from IDeclarativeSettingsForm
  32. * @psalm-import-type DeclarativeSettingsSectionType from IDeclarativeSettingsForm
  33. * @psalm-import-type DeclarativeSettingsFormSchemaWithValues from IDeclarativeSettingsForm
  34. * @psalm-import-type DeclarativeSettingsFormSchemaWithoutValues from IDeclarativeSettingsForm
  35. */
  36. interface IDeclarativeManager {
  37. /**
  38. * Registers a new declarative settings schema.
  39. *
  40. * @param DeclarativeSettingsFormSchemaWithoutValues $schema
  41. * @since 29.0.0
  42. */
  43. public function registerSchema(string $app, array $schema): void;
  44. /**
  45. * Load all schemas from the registration context and events.
  46. *
  47. * @since 29.0.0
  48. */
  49. public function loadSchemas(): void;
  50. /**
  51. * Gets the IDs of the forms for the given type and section.
  52. *
  53. * @param DeclarativeSettingsSectionType $type
  54. * @param string $section
  55. * @return array<string, list<string>>
  56. *
  57. * @since 29.0.0
  58. */
  59. public function getFormIDs(IUser $user, string $type, string $section): array;
  60. /**
  61. * Gets the forms including the field values for the given type and section.
  62. *
  63. * @param IUser $user Used for reading values from the personal section or for authorization for the admin section.
  64. * @param ?DeclarativeSettingsSectionType $type If it is null the forms will not be filtered by type.
  65. * @param ?string $section If it is null the forms will not be filtered by section.
  66. * @return list<DeclarativeSettingsFormSchemaWithValues>
  67. *
  68. * @since 29.0.0
  69. */
  70. public function getFormsWithValues(IUser $user, ?string $type, ?string $section): array;
  71. /**
  72. * Sets a value for the given field ID.
  73. *
  74. * @param IUser $user Used for storing values in the personal section or for authorization for the admin section.
  75. * @param DeclarativeSettingsValueTypes $value
  76. *
  77. * @throws Exception
  78. * @throws NotAdminException
  79. *
  80. * @since 29.0.0
  81. */
  82. public function setValue(IUser $user, string $app, string $formId, string $fieldId, mixed $value): void;
  83. }