summaryrefslogtreecommitdiffstats
path: root/apps
diff options
context:
space:
mode:
authorJulius Härtl <jus@bitgrid.net>2019-11-21 15:47:11 +0100
committerJulius Härtl <jus@bitgrid.net>2019-12-04 19:04:29 +0100
commit1593322397c02c84976657faac9d134d561565a0 (patch)
tree5c52cda412bfc34bf84f28b9361a9d51a347f15b /apps
parent17eece7fc4470828c3b03d44e0614e70848260a4 (diff)
downloadnextcloud-server-1593322397c02c84976657faac9d134d561565a0.tar.gz
nextcloud-server-1593322397c02c84976657faac9d134d561565a0.zip
Load apps dav plugins on the old webdav route
Signed-off-by: Julius Härtl <jus@bitgrid.net>
Diffstat (limited to 'apps')
-rw-r--r--apps/dav/appinfo/v1/publicwebdav.php3
-rw-r--r--apps/dav/appinfo/v1/webdav.php3
-rw-r--r--apps/dav/lib/Connector/Sabre/ServerFactory.php23
-rw-r--r--apps/dav/tests/unit/Connector/Sabre/RequestTest/RequestTestCase.php3
4 files changed, 27 insertions, 5 deletions
diff --git a/apps/dav/appinfo/v1/publicwebdav.php b/apps/dav/appinfo/v1/publicwebdav.php
index 37fcebe605c..ff64a205ef4 100644
--- a/apps/dav/appinfo/v1/publicwebdav.php
+++ b/apps/dav/appinfo/v1/publicwebdav.php
@@ -52,7 +52,8 @@ $serverFactory = new OCA\DAV\Connector\Sabre\ServerFactory(
\OC::$server->getMountManager(),
\OC::$server->getTagManager(),
\OC::$server->getRequest(),
- \OC::$server->getPreviewManager()
+ \OC::$server->getPreviewManager(),
+ \OC::$server->getEventDispatcher()
);
$requestUri = \OC::$server->getRequest()->getRequestUri();
diff --git a/apps/dav/appinfo/v1/webdav.php b/apps/dav/appinfo/v1/webdav.php
index d6dc9aa9b45..e2de6bd818e 100644
--- a/apps/dav/appinfo/v1/webdav.php
+++ b/apps/dav/appinfo/v1/webdav.php
@@ -44,7 +44,8 @@ $serverFactory = new \OCA\DAV\Connector\Sabre\ServerFactory(
\OC::$server->getMountManager(),
\OC::$server->getTagManager(),
\OC::$server->getRequest(),
- \OC::$server->getPreviewManager()
+ \OC::$server->getPreviewManager(),
+ \OC::$server->getEventDispatcher()
);
// Backends
diff --git a/apps/dav/lib/Connector/Sabre/ServerFactory.php b/apps/dav/lib/Connector/Sabre/ServerFactory.php
index 1821638189d..f1745dbd91a 100644
--- a/apps/dav/lib/Connector/Sabre/ServerFactory.php
+++ b/apps/dav/lib/Connector/Sabre/ServerFactory.php
@@ -30,6 +30,7 @@
namespace OCA\DAV\Connector\Sabre;
use OC\Files\Node\Folder;
+use OCA\DAV\AppInfo\PluginManager;
use OCA\DAV\Files\BrowserErrorPagePlugin;
use OCP\Files\Mount\IMountManager;
use OCP\IConfig;
@@ -39,7 +40,9 @@ use OCP\IPreview;
use OCP\IRequest;
use OCP\ITagManager;
use OCP\IUserSession;
+use OCP\SabrePluginEvent;
use Sabre\DAV\Auth\Plugin;
+use Symfony\Component\EventDispatcher\EventDispatcherInterface;
class ServerFactory {
/** @var IConfig */
@@ -58,6 +61,8 @@ class ServerFactory {
private $request;
/** @var IPreview */
private $previewManager;
+ /** @var EventDispatcherInterface */
+ private $eventDispatcher;
/**
* @param IConfig $config
@@ -77,7 +82,8 @@ class ServerFactory {
IMountManager $mountManager,
ITagManager $tagManager,
IRequest $request,
- IPreview $previewManager
+ IPreview $previewManager,
+ EventDispatcherInterface $eventDispatcher
) {
$this->config = $config;
$this->logger = $logger;
@@ -87,6 +93,7 @@ class ServerFactory {
$this->tagManager = $tagManager;
$this->request = $request;
$this->previewManager = $previewManager;
+ $this->eventDispatcher = $eventDispatcher;
}
/**
@@ -134,7 +141,7 @@ class ServerFactory {
$server->on('beforeMethod', function () use ($server, $objectTree, $viewCallBack) {
// ensure the skeleton is copied
$userFolder = \OC::$server->getUserFolder();
-
+
/** @var \OC\Files\View $view */
$view = $viewCallBack($server);
if ($userFolder instanceof Folder && $userFolder->getPath() === $view->getRoot()) {
@@ -195,6 +202,18 @@ class ServerFactory {
);
}
$server->addPlugin(new \OCA\DAV\Connector\Sabre\CopyEtagHeaderPlugin());
+
+ // Load dav plugins from apps
+ $event = new SabrePluginEvent($server);
+ $this->eventDispatcher->dispatch($event);
+ $pluginManager = new PluginManager(
+ \OC::$server,
+ \OC::$server->getAppManager()
+ );
+ foreach ($pluginManager->getAppPlugins() as $appPlugin) {
+ $server->addPlugin($appPlugin);
+ }
+
}, 30); // priority 30: after auth (10) and acl(20), before lock(50) and handling the request
return $server;
}
diff --git a/apps/dav/tests/unit/Connector/Sabre/RequestTest/RequestTestCase.php b/apps/dav/tests/unit/Connector/Sabre/RequestTest/RequestTestCase.php
index b7d88b2208e..b921e0fea5e 100644
--- a/apps/dav/tests/unit/Connector/Sabre/RequestTest/RequestTestCase.php
+++ b/apps/dav/tests/unit/Connector/Sabre/RequestTest/RequestTestCase.php
@@ -67,7 +67,8 @@ abstract class RequestTestCase extends TestCase {
$this->getMockBuilder(IRequest::class)
->disableOriginalConstructor()
->getMock(),
- \OC::$server->getPreviewManager()
+ \OC::$server->getPreviewManager(),
+ \OC::$server->getEventDispatcher()
);
}