IDashboardWidget.php 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143
  1. <?php
  2. declare(strict_types=1);
  3. /**
  4. * @copyright 2018, Maxence Lange <maxence@artificial-owl.com>
  5. *
  6. * @author Maxence Lange <maxence@artificial-owl.com>
  7. * @author Roeland Jago Douma <roeland@famdouma.nl>
  8. *
  9. * @license GNU AGPL version 3 or any later version
  10. *
  11. * This program is free software: you can redistribute it and/or modify
  12. * it under the terms of the GNU Affero General Public License as
  13. * published by the Free Software Foundation, either version 3 of the
  14. * License, or (at your option) any later version.
  15. *
  16. * This program is distributed in the hope that it will be useful,
  17. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  18. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  19. * GNU Affero General Public License for more details.
  20. *
  21. * You should have received a copy of the GNU Affero General Public License
  22. * along with this program. If not, see <http://www.gnu.org/licenses/>.
  23. *
  24. */
  25. namespace OCP\Dashboard;
  26. use OCP\Dashboard\Model\IWidgetConfig;
  27. use OCP\Dashboard\Model\IWidgetRequest;
  28. use OCP\Dashboard\Model\WidgetSetup;
  29. use OCP\Dashboard\Model\WidgetTemplate;
  30. /**
  31. * Interface IDashboardWidget
  32. *
  33. * This interface is used to create a widget: the widget must implement this
  34. * interface and be defined in appinfo/info.xml:
  35. *
  36. * <dashboard>
  37. * <widget>OCA\YourApp\YourWidget</widget>
  38. * </dashboard>
  39. *
  40. * Multiple widget can be defined in the same appinfo/info.xml.
  41. *
  42. * @since 15.0.0
  43. *
  44. * @package OCP\Dashboard
  45. */
  46. interface IDashboardWidget {
  47. /**
  48. * Should returns the (unique) Id of the widget.
  49. *
  50. * @since 15.0.0
  51. *
  52. * @return string
  53. */
  54. public function getId(): string;
  55. /**
  56. * Should returns the [display] name of the widget.
  57. *
  58. * @since 15.0.0
  59. *
  60. * @return string
  61. */
  62. public function getName(): string;
  63. /**
  64. * Should returns some text describing the widget.
  65. * This description is displayed in the listing of the available widgets.
  66. *
  67. * @since 15.0.0
  68. *
  69. * @return string
  70. */
  71. public function getDescription(): string;
  72. /**
  73. * Must generate and return a WidgetTemplate that define important stuff
  74. * about the Widget: icon, content, css or javascript.
  75. *
  76. * @see WidgetTemplate
  77. *
  78. * @since 15.0.0
  79. *
  80. * @return WidgetTemplate
  81. */
  82. public function getWidgetTemplate(): WidgetTemplate;
  83. /**
  84. * Must create and return a WidgetSetup containing the general setup of
  85. * the widget
  86. *
  87. * @see WidgetSetup
  88. *
  89. * @since 15.0.0
  90. *
  91. * @return WidgetSetup
  92. */
  93. public function getWidgetSetup(): WidgetSetup;
  94. /**
  95. * This method is called when a widget is loaded on the dashboard.
  96. * A widget is 'loaded on the dashboard' when one of these conditions
  97. * occurs:
  98. *
  99. * - the user is adding the widget on his dashboard,
  100. * - the user already added the widget on his dashboard and he is opening
  101. * the dashboard app.
  102. *
  103. * @see IWidgetConfig
  104. *
  105. * @since 15.0.0
  106. *
  107. * @param IWidgetConfig $settings
  108. */
  109. public function loadWidget(IWidgetConfig $settings);
  110. /**
  111. * This method s executed when the widget call the net.requestWidget()
  112. * from the Javascript API.
  113. *
  114. * This is used by the frontend to communicate with the backend.
  115. *
  116. * @see IWidgetRequest
  117. *
  118. * @since 15.0.0
  119. *
  120. * @param IWidgetRequest $request
  121. */
  122. public function requestWidget(IWidgetRequest $request);
  123. }