1
0

IWidgetRequest.php 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137
  1. <?php
  2. declare(strict_types=1);
  3. /**
  4. * Nextcloud - Dashboard App
  5. *
  6. * This file is licensed under the Affero General Public License version 3 or
  7. * later. See the COPYING file.
  8. *
  9. * @author Maxence Lange <maxence@artificial-owl.com>
  10. * @copyright 2018, Maxence Lange <maxence@artificial-owl.com>
  11. * @license GNU AGPL version 3 or any later version
  12. *
  13. * This program is free software: you can redistribute it and/or modify
  14. * it under the terms of the GNU Affero General Public License as
  15. * published by the Free Software Foundation, either version 3 of the
  16. * License, or (at your option) any later version.
  17. *
  18. * This program is distributed in the hope that it will be useful,
  19. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  20. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  21. * GNU Affero General Public License for more details.
  22. *
  23. * You should have received a copy of the GNU Affero General Public License
  24. * along with this program. If not, see <http://www.gnu.org/licenses/>.
  25. *
  26. */
  27. namespace OCP\Dashboard\Model;
  28. use OCP\Dashboard\IDashboardWidget;
  29. /**
  30. * Interface IWidgetRequest
  31. *
  32. * WidgetRequest are created by the Dashboard App and used to communicate from
  33. * the frontend to the backend.
  34. * The object is send to the WidgetClass using IDashboardWidget::requestWidget
  35. *
  36. * @see IDashboardWidget::requestWidget
  37. *
  38. * @since 15.0.0
  39. *
  40. * @package OCP\Dashboard\Model
  41. */
  42. interface IWidgetRequest {
  43. /**
  44. * Get the widgetId.
  45. *
  46. * @since 15.0.0
  47. *
  48. * @return string
  49. */
  50. public function getWidgetId(): string;
  51. /**
  52. * Get the WidgetClass.
  53. *
  54. * @since 15.0.0
  55. *
  56. * @return IDashboardWidget
  57. */
  58. public function getWidget(): IDashboardWidget;
  59. /**
  60. * Get the 'request' string sent by the request from the front-end with
  61. * the format:
  62. *
  63. * net.requestWidget(
  64. * {
  65. * widget: widgetId,
  66. * request: request,
  67. * value: value
  68. * },
  69. * callback);
  70. *
  71. * @since 15.0.0
  72. *
  73. * @return string
  74. */
  75. public function getRequest(): string;
  76. /**
  77. * Get the 'value' string sent by the request from the front-end.
  78. *
  79. * @see getRequest
  80. *
  81. * @since 15.0.0
  82. *
  83. * @return string
  84. */
  85. public function getValue(): string;
  86. /**
  87. * Returns the result.
  88. *
  89. * @since 15.0.0
  90. *
  91. * @return array
  92. */
  93. public function getResult(): array;
  94. /**
  95. * add a result (as string)
  96. *
  97. * @since 15.0.0
  98. *
  99. * @param string $key
  100. * @param string $result
  101. *
  102. * @return $this
  103. */
  104. public function addResult(string $key, string $result): IWidgetRequest;
  105. /**
  106. * add a result (as array)
  107. *
  108. * @since 15.0.0
  109. *
  110. * @param string $key
  111. * @param array $result
  112. *
  113. * @return $this
  114. */
  115. public function addResultArray(string $key, array $result): IWidgetRequest;
  116. }