From fb9dfb67ba1963e12040c107e8404a28904b3791 Mon Sep 17 00:00:00 2001 From: Julien Veyssier Date: Mon, 19 Dec 2022 12:17:35 +0100 Subject: [PATCH] manual backport of #35789, dispatch BeforeSabrePubliclyLoadedEvent to allow adding additional Sabre plugins in publicwebdav.php Signed-off-by: Julien Veyssier --- apps/dav/appinfo/v1/publicwebdav.php | 7 +++++ lib/composer/composer/autoload_classmap.php | 1 + lib/composer/composer/autoload_static.php | 1 + lib/public/BeforeSabrePubliclyLoadedEvent.php | 31 +++++++++++++++++++ 4 files changed, 40 insertions(+) create mode 100644 lib/public/BeforeSabrePubliclyLoadedEvent.php diff --git a/apps/dav/appinfo/v1/publicwebdav.php b/apps/dav/appinfo/v1/publicwebdav.php index 409fbbcf4a717..5530fc2cc7d31 100644 --- a/apps/dav/appinfo/v1/publicwebdav.php +++ b/apps/dav/appinfo/v1/publicwebdav.php @@ -30,6 +30,8 @@ * */ +use OCP\BeforeSabrePubliclyLoadedEvent; +use OCP\EventDispatcher\IEventDispatcher; use Psr\Log\LoggerInterface; // load needed apps @@ -111,6 +113,11 @@ $server->addPlugin($linkCheckPlugin); $server->addPlugin($filesDropPlugin); +// allow setup of additional plugins +$event = new BeforeSabrePubliclyLoadedEvent($server); +/** @var IEventDispatcher $eventDispatcher */ +$eventDispatcher = \OC::$server->get(IEventDispatcher::class); +$eventDispatcher->dispatchTyped($event); // And off we go! $server->exec(); diff --git a/lib/composer/composer/autoload_classmap.php b/lib/composer/composer/autoload_classmap.php index 55902b5e48775..80791f61931c3 100644 --- a/lib/composer/composer/autoload_classmap.php +++ b/lib/composer/composer/autoload_classmap.php @@ -114,6 +114,7 @@ 'OCP\\BackgroundJob\\Job' => $baseDir . '/lib/public/BackgroundJob/Job.php', 'OCP\\BackgroundJob\\QueuedJob' => $baseDir . '/lib/public/BackgroundJob/QueuedJob.php', 'OCP\\BackgroundJob\\TimedJob' => $baseDir . '/lib/public/BackgroundJob/TimedJob.php', + 'OCP\\BeforeSabrePubliclyLoadedEvent' => $baseDir . '/lib/public/BeforeSabrePubliclyLoadedEvent.php', 'OCP\\Broadcast\\Events\\IBroadcastEvent' => $baseDir . '/lib/public/Broadcast/Events/IBroadcastEvent.php', 'OCP\\Cache\\CappedMemoryCache' => $baseDir . '/lib/public/Cache/CappedMemoryCache.php', 'OCP\\Calendar\\BackendTemporarilyUnavailableException' => $baseDir . '/lib/public/Calendar/BackendTemporarilyUnavailableException.php', diff --git a/lib/composer/composer/autoload_static.php b/lib/composer/composer/autoload_static.php index eb22194d44d0e..7248dfddea20b 100644 --- a/lib/composer/composer/autoload_static.php +++ b/lib/composer/composer/autoload_static.php @@ -147,6 +147,7 @@ class ComposerStaticInit749170dad3f5e7f9ca158f5a9f04f6a2 'OCP\\BackgroundJob\\Job' => __DIR__ . '/../../..' . '/lib/public/BackgroundJob/Job.php', 'OCP\\BackgroundJob\\QueuedJob' => __DIR__ . '/../../..' . '/lib/public/BackgroundJob/QueuedJob.php', 'OCP\\BackgroundJob\\TimedJob' => __DIR__ . '/../../..' . '/lib/public/BackgroundJob/TimedJob.php', + 'OCP\\BeforeSabrePubliclyLoadedEvent' => __DIR__ . '/../../..' . '/lib/public/BeforeSabrePubliclyLoadedEvent.php', 'OCP\\Broadcast\\Events\\IBroadcastEvent' => __DIR__ . '/../../..' . '/lib/public/Broadcast/Events/IBroadcastEvent.php', 'OCP\\Cache\\CappedMemoryCache' => __DIR__ . '/../../..' . '/lib/public/Cache/CappedMemoryCache.php', 'OCP\\Calendar\\BackendTemporarilyUnavailableException' => __DIR__ . '/../../..' . '/lib/public/Calendar/BackendTemporarilyUnavailableException.php', diff --git a/lib/public/BeforeSabrePubliclyLoadedEvent.php b/lib/public/BeforeSabrePubliclyLoadedEvent.php new file mode 100644 index 0000000000000..410e9bbe7ac12 --- /dev/null +++ b/lib/public/BeforeSabrePubliclyLoadedEvent.php @@ -0,0 +1,31 @@ + 2022 + * + * @author Julien Veyssier + * + * @license AGPL-3.0-or-later + * + * This code is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License, version 3, + * as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License, version 3, + * along with this program. If not, see + * + */ +namespace OCP; + +/** + * Dispatched before Sabre is loaded when accessing public webdav endpoints + * This can be used to inject a Sabre plugin for example + * + * @since 25.0.0 + */ +class BeforeSabrePubliclyLoadedEvent extends SabrePluginEvent { +}