Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nextcloud/server.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
Diffstat (limited to 'lib')
-rw-r--r--lib/base.php4
-rw-r--r--lib/composer/composer/autoload_classmap.php1
-rw-r--r--lib/composer/composer/autoload_static.php1
-rw-r--r--lib/private/Collaboration/Resources/Listener.php33
-rw-r--r--lib/public/Collaboration/Resources/LoadAdditionalScriptsEvent.php40
5 files changed, 72 insertions, 7 deletions
diff --git a/lib/base.php b/lib/base.php
index 8cf5360b084..cd9f4fc2478 100644
--- a/lib/base.php
+++ b/lib/base.php
@@ -62,9 +62,11 @@
*
*/
+use OC\EventDispatcher\SymfonyAdapter;
use OCP\EventDispatcher\IEventDispatcher;
use OCP\Group\Events\UserRemovedEvent;
use OCP\ILogger;
+use OCP\Server;
use OCP\Share;
use OC\Encryption\HookManager;
use OC\Files\Filesystem;
@@ -881,7 +883,7 @@ class OC {
}
private static function registerResourceCollectionHooks() {
- \OC\Collaboration\Resources\Listener::register(\OC::$server->getEventDispatcher());
+ \OC\Collaboration\Resources\Listener::register(Server::get(SymfonyAdapter::class), Server::get(IEventDispatcher::class));
}
/**
diff --git a/lib/composer/composer/autoload_classmap.php b/lib/composer/composer/autoload_classmap.php
index 233c374edbf..96666ee6021 100644
--- a/lib/composer/composer/autoload_classmap.php
+++ b/lib/composer/composer/autoload_classmap.php
@@ -148,6 +148,7 @@ return array(
'OCP\\Collaboration\\Resources\\IProvider' => $baseDir . '/lib/public/Collaboration/Resources/IProvider.php',
'OCP\\Collaboration\\Resources\\IProviderManager' => $baseDir . '/lib/public/Collaboration/Resources/IProviderManager.php',
'OCP\\Collaboration\\Resources\\IResource' => $baseDir . '/lib/public/Collaboration/Resources/IResource.php',
+ 'OCP\\Collaboration\\Resources\\LoadAdditionalScriptsEvent' => $baseDir . '/lib/public/Collaboration/Resources/LoadAdditionalScriptsEvent.php',
'OCP\\Collaboration\\Resources\\ResourceException' => $baseDir . '/lib/public/Collaboration/Resources/ResourceException.php',
'OCP\\Command\\IBus' => $baseDir . '/lib/public/Command/IBus.php',
'OCP\\Command\\ICommand' => $baseDir . '/lib/public/Command/ICommand.php',
diff --git a/lib/composer/composer/autoload_static.php b/lib/composer/composer/autoload_static.php
index 0b59d14657d..ddea8460724 100644
--- a/lib/composer/composer/autoload_static.php
+++ b/lib/composer/composer/autoload_static.php
@@ -177,6 +177,7 @@ class ComposerStaticInit53792487c5a8370acc0b06b1a864ff4c
'OCP\\Collaboration\\Resources\\IProvider' => __DIR__ . '/../../..' . '/lib/public/Collaboration/Resources/IProvider.php',
'OCP\\Collaboration\\Resources\\IProviderManager' => __DIR__ . '/../../..' . '/lib/public/Collaboration/Resources/IProviderManager.php',
'OCP\\Collaboration\\Resources\\IResource' => __DIR__ . '/../../..' . '/lib/public/Collaboration/Resources/IResource.php',
+ 'OCP\\Collaboration\\Resources\\LoadAdditionalScriptsEvent' => __DIR__ . '/../../..' . '/lib/public/Collaboration/Resources/LoadAdditionalScriptsEvent.php',
'OCP\\Collaboration\\Resources\\ResourceException' => __DIR__ . '/../../..' . '/lib/public/Collaboration/Resources/ResourceException.php',
'OCP\\Command\\IBus' => __DIR__ . '/../../..' . '/lib/public/Command/IBus.php',
'OCP\\Command\\ICommand' => __DIR__ . '/../../..' . '/lib/public/Command/ICommand.php',
diff --git a/lib/private/Collaboration/Resources/Listener.php b/lib/private/Collaboration/Resources/Listener.php
index ba012b4ca44..b9f1e72cbfa 100644
--- a/lib/private/Collaboration/Resources/Listener.php
+++ b/lib/private/Collaboration/Resources/Listener.php
@@ -26,14 +26,16 @@ declare(strict_types=1);
*/
namespace OC\Collaboration\Resources;
+use OC\EventDispatcher\SymfonyAdapter;
use OCP\Collaboration\Resources\IManager;
+use OCP\Collaboration\Resources\LoadAdditionalScriptsEvent;
+use OCP\EventDispatcher\IEventDispatcher;
use OCP\IGroup;
use OCP\IUser;
-use Symfony\Component\EventDispatcher\EventDispatcherInterface;
use Symfony\Component\EventDispatcher\GenericEvent;
class Listener {
- public static function register(EventDispatcherInterface $dispatcher): void {
+ public static function register(SymfonyAdapter $symfonyDispatcher, IEventDispatcher $eventDispatcher): void {
$listener = function (GenericEvent $event) {
/** @var IUser $user */
$user = $event->getArgument('user');
@@ -42,10 +44,10 @@ class Listener {
$resourceManager->invalidateAccessCacheForUser($user);
};
- $dispatcher->addListener(IGroup::class . '::postAddUser', $listener);
- $dispatcher->addListener(IGroup::class . '::postRemoveUser', $listener);
+ $symfonyDispatcher->addListener(IGroup::class . '::postAddUser', $listener);
+ $symfonyDispatcher->addListener(IGroup::class . '::postRemoveUser', $listener);
- $dispatcher->addListener(IUser::class . '::postDelete', function (GenericEvent $event) {
+ $symfonyDispatcher->addListener(IUser::class . '::postDelete', function (GenericEvent $event) {
/** @var IUser $user */
$user = $event->getSubject();
/** @var IManager $resourceManager */
@@ -54,7 +56,7 @@ class Listener {
$resourceManager->invalidateAccessCacheForUser($user);
});
- $dispatcher->addListener(IGroup::class . '::preDelete', function (GenericEvent $event) {
+ $symfonyDispatcher->addListener(IGroup::class . '::preDelete', function (GenericEvent $event) {
/** @var IGroup $group */
$group = $event->getSubject();
/** @var IManager $resourceManager */
@@ -64,5 +66,24 @@ class Listener {
$resourceManager->invalidateAccessCacheForUser($user);
}
});
+
+ // Stay backward compatible with the legacy event for now
+ $fallbackEventRunning = false;
+ $symfonyDispatcher->addListener('\OCP\Collaboration\Resources::loadAdditionalScripts', function () use ($eventDispatcher, &$fallbackEventRunning) {
+ if ($fallbackEventRunning) {
+ return;
+ }
+ $fallbackEventRunning = true;
+ $eventDispatcher->dispatchTyped(new LoadAdditionalScriptsEvent());
+ $fallbackEventRunning = false;
+ });
+ $eventDispatcher->addListener(LoadAdditionalScriptsEvent::class, static function () use ($symfonyDispatcher, &$fallbackEventRunning) {
+ if ($fallbackEventRunning) {
+ return;
+ }
+ $fallbackEventRunning = true;
+ $symfonyDispatcher->dispatch('\OCP\Collaboration\Resources::loadAdditionalScripts');
+ $fallbackEventRunning = false;
+ });
}
}
diff --git a/lib/public/Collaboration/Resources/LoadAdditionalScriptsEvent.php b/lib/public/Collaboration/Resources/LoadAdditionalScriptsEvent.php
new file mode 100644
index 00000000000..2f1dc5a0a00
--- /dev/null
+++ b/lib/public/Collaboration/Resources/LoadAdditionalScriptsEvent.php
@@ -0,0 +1,40 @@
+<?php
+
+declare(strict_types=1);
+
+/**
+ * @copyright Copyright (c) 2022 Julius Härtl <jus@bitgrid.net>
+ *
+ * @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 OCP\Collaboration\Resources;
+
+use OCP\EventDispatcher\Event;
+
+/**
+ * This event is used by apps to register their own frontend scripts for integrating
+ * projects in their app. Apps also need to dispatch the event in order to load
+ * scripts during page load
+ *
+ * @see https://docs.nextcloud.com/server/latest/developer_manual/digging_deeper/projects.html
+ * @since 25.0.0
+ */
+class LoadAdditionalScriptsEvent extends Event {
+}