ServerPlugin.php 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105
  1. <?php
  2. declare(strict_types=1);
  3. namespace Sabre\DAV;
  4. /**
  5. * The baseclass for all server plugins.
  6. *
  7. * Plugins can modify or extend the servers behaviour.
  8. *
  9. * @copyright Copyright (C) fruux GmbH (https://fruux.com/)
  10. * @author Evert Pot (http://evertpot.com/)
  11. * @license http://sabre.io/license/ Modified BSD License
  12. */
  13. abstract class ServerPlugin
  14. {
  15. /**
  16. * This initializes the plugin.
  17. *
  18. * This function is called by Sabre\DAV\Server, after
  19. * addPlugin is called.
  20. *
  21. * This method should set up the required event subscriptions.
  22. */
  23. abstract public function initialize(Server $server);
  24. /**
  25. * This method should return a list of server-features.
  26. *
  27. * This is for example 'versioning' and is added to the DAV: header
  28. * in an OPTIONS response.
  29. *
  30. * @return array
  31. */
  32. public function getFeatures()
  33. {
  34. return [];
  35. }
  36. /**
  37. * Use this method to tell the server this plugin defines additional
  38. * HTTP methods.
  39. *
  40. * This method is passed a uri. It should only return HTTP methods that are
  41. * available for the specified uri.
  42. *
  43. * @param string $path
  44. *
  45. * @return array
  46. */
  47. public function getHTTPMethods($path)
  48. {
  49. return [];
  50. }
  51. /**
  52. * Returns a plugin name.
  53. *
  54. * Using this name other plugins will be able to access other plugins
  55. * using \Sabre\DAV\Server::getPlugin
  56. *
  57. * @return string
  58. */
  59. public function getPluginName()
  60. {
  61. return get_class($this);
  62. }
  63. /**
  64. * Returns a list of reports this plugin supports.
  65. *
  66. * This will be used in the {DAV:}supported-report-set property.
  67. * Note that you still need to subscribe to the 'report' event to actually
  68. * implement them
  69. *
  70. * @param string $uri
  71. *
  72. * @return array
  73. */
  74. public function getSupportedReportSet($uri)
  75. {
  76. return [];
  77. }
  78. /**
  79. * Returns a bunch of meta-data about the plugin.
  80. *
  81. * Providing this information is optional, and is mainly displayed by the
  82. * Browser plugin.
  83. *
  84. * The description key in the returned array may contain html and will not
  85. * be sanitized.
  86. *
  87. * @return array
  88. */
  89. public function getPluginInfo()
  90. {
  91. return [
  92. 'name' => $this->getPluginName(),
  93. 'description' => null,
  94. 'link' => null,
  95. ];
  96. }
  97. }