aboutsummaryrefslogtreecommitdiffstats
path: root/apps/files_sharing/lib
diff options
context:
space:
mode:
authorJoas Schilling <213943+nickvergessen@users.noreply.github.com>2023-08-04 10:39:57 +0200
committerGitHub <noreply@github.com>2023-08-04 10:39:57 +0200
commit44b4c16a091592203df51c19d0be1b520bc3ad9b (patch)
tree25ee31ab54832dc2bc984f4f91940c30dcb8ac33 /apps/files_sharing/lib
parentf8bd676154f988ef2130ccb0e29b0cc95e42a204 (diff)
parent3962cd0aa8ab7530deffa3b41cab2e11a01fd14a (diff)
downloadnextcloud-server-44b4c16a091592203df51c19d0be1b520bc3ad9b.tar.gz
nextcloud-server-44b4c16a091592203df51c19d0be1b520bc3ad9b.zip
Merge pull request #39605 from nextcloud/bugfix/noid/final-events-cleanup
fix!: Final round of moving to IEventDispatcher
Diffstat (limited to 'apps/files_sharing/lib')
-rw-r--r--apps/files_sharing/lib/AppInfo/Application.php7
-rw-r--r--apps/files_sharing/lib/Listener/LegacyBeforeTemplateRenderedListener.php57
-rw-r--r--apps/files_sharing/lib/Notification/Listener.php9
3 files changed, 4 insertions, 69 deletions
diff --git a/apps/files_sharing/lib/AppInfo/Application.php b/apps/files_sharing/lib/AppInfo/Application.php
index 65197e9b270..d89419b8ea9 100644
--- a/apps/files_sharing/lib/AppInfo/Application.php
+++ b/apps/files_sharing/lib/AppInfo/Application.php
@@ -37,7 +37,6 @@ use OCA\Files_Sharing\Event\BeforeTemplateRenderedEvent;
use OCA\Files_Sharing\External\Manager;
use OCA\Files_Sharing\External\MountProvider as ExternalMountProvider;
use OCA\Files_Sharing\Helper;
-use OCA\Files_Sharing\Listener\LegacyBeforeTemplateRenderedListener;
use OCA\Files_Sharing\Listener\LoadAdditionalListener;
use OCA\Files_Sharing\Listener\LoadSidebarListener;
use OCA\Files_Sharing\Listener\ShareInteractionListener;
@@ -133,7 +132,6 @@ class Application extends App implements IBootstrap {
public function registerEventsScripts(IEventDispatcher $dispatcher): void {
// sidebar and files scripts
$dispatcher->addServiceListener(LoadAdditionalScriptsEvent::class, LoadAdditionalListener::class);
- $dispatcher->addServiceListener(BeforeTemplateRenderedEvent::class, LegacyBeforeTemplateRenderedListener::class);
$dispatcher->addServiceListener(LoadSidebar::class, LoadSidebarListener::class);
$dispatcher->addServiceListener(ShareCreatedEvent::class, ShareInteractionListener::class);
$dispatcher->addServiceListener(ShareCreatedEvent::class, UserShareAcceptanceListener::class);
@@ -143,10 +141,7 @@ class Application extends App implements IBootstrap {
});
// notifications api to accept incoming user shares
- $dispatcher->addListener('OCP\Share::postShare', function ($event) {
- if (!$event instanceof OldGenericEvent) {
- return;
- }
+ $dispatcher->addListener(ShareCreatedEvent::class, function (ShareCreatedEvent $event) {
/** @var Listener $listener */
$listener = $this->getContainer()->query(Listener::class);
$listener->shareNotification($event);
diff --git a/apps/files_sharing/lib/Listener/LegacyBeforeTemplateRenderedListener.php b/apps/files_sharing/lib/Listener/LegacyBeforeTemplateRenderedListener.php
deleted file mode 100644
index e7e81c3a17a..00000000000
--- a/apps/files_sharing/lib/Listener/LegacyBeforeTemplateRenderedListener.php
+++ /dev/null
@@ -1,57 +0,0 @@
-<?php
-
-declare(strict_types=1);
-
-/**
- * @copyright Copyright (c) 2019, Roeland Jago Douma <roeland@famdouma.nl>
- *
- * @author Julius Härtl <jus@bitgrid.net>
- *
- * @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\Files_Sharing\Listener;
-
-use OC\EventDispatcher\SymfonyAdapter;
-use OCA\Files_Sharing\Event\BeforeTemplateRenderedEvent;
-use OCP\EventDispatcher\Event;
-use OCP\EventDispatcher\IEventListener;
-use Symfony\Component\EventDispatcher\GenericEvent;
-
-class LegacyBeforeTemplateRenderedListener implements IEventListener {
-
- /** @var SymfonyAdapter */
- private $dispatcher;
-
- public function __construct(SymfonyAdapter $dispatcher) {
- $this->dispatcher = $dispatcher;
- }
-
- public function handle(Event $event): void {
- if (!($event instanceof BeforeTemplateRenderedEvent)) {
- return;
- }
-
- $eventName = 'OCA\Files_Sharing::loadAdditionalScripts';
-
- if ($event->getScope() !== null) {
- $eventName .= '::' . $event->getScope();
- }
-
- $legacyEvent = new GenericEvent(null, ['share' => $event->getShare()]);
- $this->dispatcher->dispatch($eventName, $legacyEvent);
- }
-}
diff --git a/apps/files_sharing/lib/Notification/Listener.php b/apps/files_sharing/lib/Notification/Listener.php
index db7939767d6..b6d30cdb3f5 100644
--- a/apps/files_sharing/lib/Notification/Listener.php
+++ b/apps/files_sharing/lib/Notification/Listener.php
@@ -31,6 +31,7 @@ use OCP\IGroupManager;
use OCP\IUser;
use OCP\Notification\IManager as INotificationManager;
use OCP\Notification\INotification;
+use OCP\Share\Events\ShareCreatedEvent;
use OCP\Share\IManager as IShareManager;
use OCP\Share\IShare;
use Symfony\Component\EventDispatcher\GenericEvent;
@@ -54,12 +55,8 @@ class Listener {
$this->groupManager = $groupManager;
}
- /**
- * @param GenericEvent $event
- */
- public function shareNotification(GenericEvent $event): void {
- /** @var IShare $share */
- $share = $event->getSubject();
+ public function shareNotification(ShareCreatedEvent $event): void {
+ $share = $event->getShare();
$notification = $this->instantiateNotification($share);
if ($share->getShareType() === IShare::TYPE_USER) {