aboutsummaryrefslogtreecommitdiffstats
path: root/lib/private
diff options
context:
space:
mode:
authorCarl Schwan <carl@carlschwan.eu>2022-05-27 18:36:40 +0200
committerGitHub <noreply@github.com>2022-05-27 18:36:40 +0200
commite4378fd18cb39407097f40431cd28c1fa01ba75d (patch)
treec4b3cd4a8fb79afe6a5ab680625c3664fdaa8f66 /lib/private
parentac79137816709b4adc6b2e21cc52c807381c4baf (diff)
parentae0e9ff0834e9446d14d58b5dfbc5cc90794f760 (diff)
downloadnextcloud-server-e4378fd18cb39407097f40431cd28c1fa01ba75d.tar.gz
nextcloud-server-e4378fd18cb39407097f40431cd28c1fa01ba75d.zip
Merge pull request #32349 from nextcloud/enh/projects-event
Add event to load additional scripts for projects
Diffstat (limited to 'lib/private')
-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;
+ });
}
}