Skip to content

Commit

Permalink
chore(files_reminders): Register dav plugin directly
Browse files Browse the repository at this point in the history
Signed-off-by: Christopher Ng <chrng8@gmail.com>
  • Loading branch information
Pytal committed Mar 8, 2024
1 parent 810bb64 commit 5ae3556
Show file tree
Hide file tree
Showing 5 changed files with 57 additions and 10 deletions.
10 changes: 0 additions & 10 deletions apps/files_reminders/appinfo/info.xml
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,6 @@ Set file reminders.
<author>Christopher Ng</author>
<namespace>FilesReminders</namespace>

<types>
<dav />
</types>

<category>files</category>

<bugs>https://github.com/nextcloud/server/issues</bugs>
Expand All @@ -33,10 +29,4 @@ Set file reminders.
<commands>
<command>OCA\FilesReminders\Command\ListCommand</command>
</commands>

<sabre>
<plugins>
<plugin>OCA\FilesReminders\Dav\PropFindPlugin</plugin>
</plugins>
</sabre>
</info>
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
'OCA\\FilesReminders\\Exception\\UserNotFoundException' => $baseDir . '/../lib/Exception/UserNotFoundException.php',
'OCA\\FilesReminders\\Listener\\LoadAdditionalScriptsListener' => $baseDir . '/../lib/Listener/LoadAdditionalScriptsListener.php',
'OCA\\FilesReminders\\Listener\\NodeDeletedListener' => $baseDir . '/../lib/Listener/NodeDeletedListener.php',
'OCA\\FilesReminders\\Listener\\SabrePluginAddListener' => $baseDir . '/../lib/Listener/SabrePluginAddListener.php',
'OCA\\FilesReminders\\Listener\\UserDeletedListener' => $baseDir . '/../lib/Listener/UserDeletedListener.php',
'OCA\\FilesReminders\\Migration\\Version10000Date20230725162149' => $baseDir . '/../lib/Migration/Version10000Date20230725162149.php',
'OCA\\FilesReminders\\Model\\RichReminder' => $baseDir . '/../lib/Model/RichReminder.php',
Expand Down
1 change: 1 addition & 0 deletions apps/files_reminders/composer/composer/autoload_static.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ class ComposerStaticInitFilesReminders
'OCA\\FilesReminders\\Exception\\UserNotFoundException' => __DIR__ . '/..' . '/../lib/Exception/UserNotFoundException.php',
'OCA\\FilesReminders\\Listener\\LoadAdditionalScriptsListener' => __DIR__ . '/..' . '/../lib/Listener/LoadAdditionalScriptsListener.php',
'OCA\\FilesReminders\\Listener\\NodeDeletedListener' => __DIR__ . '/..' . '/../lib/Listener/NodeDeletedListener.php',
'OCA\\FilesReminders\\Listener\\SabrePluginAddListener' => __DIR__ . '/..' . '/../lib/Listener/SabrePluginAddListener.php',
'OCA\\FilesReminders\\Listener\\UserDeletedListener' => __DIR__ . '/..' . '/../lib/Listener/UserDeletedListener.php',
'OCA\\FilesReminders\\Migration\\Version10000Date20230725162149' => __DIR__ . '/..' . '/../lib/Migration/Version10000Date20230725162149.php',
'OCA\\FilesReminders\\Model\\RichReminder' => __DIR__ . '/..' . '/../lib/Model/RichReminder.php',
Expand Down
4 changes: 4 additions & 0 deletions apps/files_reminders/lib/AppInfo/Application.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,11 @@

namespace OCA\FilesReminders\AppInfo;

use OCA\DAV\Events\SabrePluginAddEvent;
use OCA\Files\Event\LoadAdditionalScriptsEvent;
use OCA\FilesReminders\Listener\LoadAdditionalScriptsListener;
use OCA\FilesReminders\Listener\NodeDeletedListener;
use OCA\FilesReminders\Listener\SabrePluginAddListener;
use OCA\FilesReminders\Listener\UserDeletedListener;
use OCA\FilesReminders\Notification\Notifier;
use OCP\AppFramework\App;
Expand All @@ -51,6 +53,8 @@ public function boot(IBootContext $context): void {
public function register(IRegistrationContext $context): void {
$context->registerNotifierService(Notifier::class);

$context->registerEventListener(SabrePluginAddEvent::class, SabrePluginAddListener::class);

$context->registerEventListener(NodeDeletedEvent::class, NodeDeletedListener::class);
$context->registerEventListener(UserDeletedEvent::class, UserDeletedListener::class);

Expand Down
51 changes: 51 additions & 0 deletions apps/files_reminders/lib/Listener/SabrePluginAddListener.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
<?php

declare(strict_types=1);

/**
* @copyright 2024 Christopher Ng <chrng8@gmail.com>
*
* @author Christopher Ng <chrng8@gmail.com>
*
* @license GNU AGPL version 3 or any later version
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* 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
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/

namespace OCA\FilesReminders\Listener;

use OCA\DAV\Events\SabrePluginAddEvent;
use OCA\FilesReminders\Dav\PropFindPlugin;
use OCP\EventDispatcher\Event;
use OCP\EventDispatcher\IEventListener;
use Psr\Container\ContainerInterface;

/** @template-implements IEventListener<SabrePluginAddEvent> */
class SabrePluginAddListener implements IEventListener {
public function __construct(
private ContainerInterface $container,
) {
}

public function handle(Event $event): void {
if (!($event instanceof SabrePluginAddEvent)) {
return;
}

$server = $event->getServer();
$plugin = $this->container->get(PropFindPlugin::class);
$server->addPlugin($plugin);
}
}

0 comments on commit 5ae3556

Please sign in to comment.