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.

DeclarativeSettingsGetValueEvent.php 1.3KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. <?php
  2. namespace OCP\Settings\Events;
  3. use Exception;
  4. use OCP\EventDispatcher\Event;
  5. use OCP\IUser;
  6. use OCP\Settings\IDeclarativeSettingsForm;
  7. /**
  8. * @psalm-import-type DeclarativeSettingsValueTypes from IDeclarativeSettingsForm
  9. *
  10. * @since 29.0.0
  11. */
  12. class DeclarativeSettingsGetValueEvent extends Event {
  13. /**
  14. * @var ?DeclarativeSettingsValueTypes
  15. */
  16. private mixed $value = null;
  17. /**
  18. * @since 29.0.0
  19. */
  20. public function __construct(
  21. private IUser $user,
  22. private string $app,
  23. private string $formId,
  24. private string $fieldId,
  25. ) {
  26. parent::__construct();
  27. }
  28. /**
  29. * @since 29.0.0
  30. */
  31. public function getUser(): IUser {
  32. return $this->user;
  33. }
  34. /**
  35. * @since 29.0.0
  36. */
  37. public function getApp(): string {
  38. return $this->app;
  39. }
  40. /**
  41. * @since 29.0.0
  42. */
  43. public function getFormId(): string {
  44. return $this->formId;
  45. }
  46. /**
  47. * @since 29.0.0
  48. */
  49. public function getFieldId(): string {
  50. return $this->fieldId;
  51. }
  52. /**
  53. * @since 29.0.0
  54. */
  55. public function setValue(mixed $value): void {
  56. $this->value = $value;
  57. }
  58. /**
  59. * @return DeclarativeSettingsValueTypes
  60. * @throws Exception
  61. *
  62. * @since 29.0.0
  63. */
  64. public function getValue(): mixed {
  65. if ($this->value === null) {
  66. throw new Exception('Value not set');
  67. }
  68. return $this->value;
  69. }
  70. }