Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 7 additions & 9 deletions lib/AppInfo/Application.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@

use Exception;
use OC\Files\Filesystem;
use OCA\DAV\Events\SabrePluginAddEvent;
use OCA\Registration\Events\PassedFormEvent;
use OCA\Registration\Events\ShowFormEvent;
use OCA\Registration\Events\ValidateFormEvent;
Expand All @@ -30,7 +31,6 @@
use OCP\IUser;
use OCP\IUserSession;
use OCP\Notification\IManager;
use OCP\SabrePluginEvent;
use OCP\User\Events\UserDeletedEvent;
use OCP\User\Events\UserFirstTimeLoggedInEvent;
use OCP\Util;
Expand Down Expand Up @@ -61,16 +61,14 @@ public function boot(IBootContext $context): void {
Util::connectHook('OC_Filesystem', 'preSetup', $this, 'addStorageWrapper');

$eventDispatcher = $context->getServerContainer()->get(IEventDispatcher::class);
$eventDispatcher->addListener('OCA\DAV\Connector\Sabre::addPlugin', function (SabrePluginEvent $event) use ($context): void {
$eventDispatcher->addListener(SabrePluginAddEvent::class, function (SabrePluginAddEvent $event) use ($context): void {
$eventServer = $event->getServer();

if ($eventServer !== null) {
// We have to register the CheckPlugin here and not info.xml,
// because info.xml plugins are loaded, after the
// beforeMethod:* hook has already been emitted.
$plugin = $context->getAppContainer()->get(CheckPlugin::class);
$eventServer->addPlugin($plugin);
}
// We have to register the CheckPlugin here and not info.xml,
// because info.xml plugins are loaded, after the
// beforeMethod:* hook has already been emitted.
$plugin = $context->getAppContainer()->get(CheckPlugin::class);
$eventServer->addPlugin($plugin);
});

$context->injectFn($this->registerNotifier(...));
Expand Down
1 change: 1 addition & 0 deletions psalm.xml
Original file line number Diff line number Diff line change
Expand Up @@ -50,5 +50,6 @@
<stubs>
<file name="tests/stubs/filesystem.php"/>
<file name="tests/stubs/registration.php"/>
<file name="tests/stubs/oca_dav_events_sabrepluginaddevent.php"/>
</stubs>
</psalm>
35 changes: 35 additions & 0 deletions tests/stubs/oca_dav_events_sabrepluginaddevent.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
<?php

declare(strict_types=1);

/**
* SPDX-FileCopyrightText: 2023 Nextcloud GmbH and Nextcloud contributors
* SPDX-License-Identifier: AGPL-3.0-or-later
*/
namespace OCA\DAV\Events;

use OCP\EventDispatcher\Event;
use Sabre\DAV\Server;

/**
* This event is triggered during the setup of the SabreDAV server to allow the
* registration of additional plugins.
*
* @since 28.0.0
*/
class SabrePluginAddEvent extends Event {

/**
* @since 28.0.0
*/
public function __construct(
private Server $server,
) {
}

/**
* @since 28.0.0
*/
public function getServer(): Server {
}
}
Loading