request = $request; $this->baseUri = $baseUri; $root = new RootCollection(); $this->server = new \OCA\DAV\Connector\Sabre\Server($root); // Backends $authBackend = new Auth( \OC::$server->getSession(), \OC::$server->getUserSession() ); // Set URL explicitly due to reverse-proxy situations $this->server->httpRequest->setUrl($this->request->getRequestUri()); $this->server->setBaseUri($this->baseUri); $this->server->addPlugin(new BlockLegacyClientPlugin(\OC::$server->getConfig())); $this->server->addPlugin(new Plugin($authBackend, 'ownCloud')); $this->server->addPlugin(new \Sabre\DAVACL\Plugin()); $this->server->addPlugin(new \Sabre\CardDAV\Plugin()); // wait with registering these until auth is handled and the filesystem is setup $this->server->on('beforeMethod', function () { // custom properties plugin must be the last one $user = \OC::$server->getUserSession()->getUser(); if (!is_null($user)) { $this->server->addPlugin( new \Sabre\DAV\PropertyStorage\Plugin( new CustomPropertiesBackend( $this->server->tree, \OC::$server->getDatabaseConnection(), \OC::$server->getUserSession()->getUser() ) ) ); } }); } public function exec() { $this->server->exec(); } }