aboutsummaryrefslogtreecommitdiffstats
path: root/lib/private/Collaboration/Resources
diff options
context:
space:
mode:
authorJulius Härtl <jus@bitgrid.net>2022-05-12 10:18:40 +0200
committerJulius Härtl <jus@bitgrid.net>2022-05-12 10:50:13 +0200
commit9a6869943e9a929cd2e0331c1d25d07f03d865e9 (patch)
tree6616cb956e99969158efa0b08289a6f608d21f14 /lib/private/Collaboration/Resources
parentbe49f79503a9e187cec43fabeb6f5eed9b06af6c (diff)
downloadnextcloud-server-9a6869943e9a929cd2e0331c1d25d07f03d865e9.tar.gz
nextcloud-server-9a6869943e9a929cd2e0331c1d25d07f03d865e9.zip
Introduce event for loading additional script on projects
Signed-off-by: Julius Härtl <jus@bitgrid.net>
Diffstat (limited to 'lib/private/Collaboration/Resources')
-rw-r--r--lib/private/Collaboration/Resources/Listener.php33
1 files changed, 27 insertions, 6 deletions
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;
+ });
}
}