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