diff options
author | Joas Schilling <213943+nickvergessen@users.noreply.github.com> | 2022-04-26 10:04:33 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-04-26 10:04:33 +0300 |
commit | a449038406b75e28d92070a38399b9d9de6e034a (patch) | |
tree | 3405b4423a2af3399284d67cf3190bc4d91ed052 | |
parent | a89182648a5a87e76059ca498878677db796ff5b (diff) | |
parent | 41cbc76ae335e892704ce9f7b1c10ca05ca55a08 (diff) |
Merge pull request #7215 from nextcloud/feature/move-sharing-listeners-anonymous-functions-to-static
Move sharing listeners to static
-rw-r--r-- | lib/Listener/RestrictStartingCalls.php | 12 | ||||
-rw-r--r-- | tests/php/Listener/RestrictStartingCallsTest.php | 2 |
2 files changed, 7 insertions, 7 deletions
diff --git a/lib/Listener/RestrictStartingCalls.php b/lib/Listener/RestrictStartingCalls.php index ed041ef0c..59e95639c 100644 --- a/lib/Listener/RestrictStartingCalls.php +++ b/lib/Listener/RestrictStartingCalls.php @@ -42,18 +42,16 @@ class RestrictStartingCalls { } public static function register(IEventDispatcher $dispatcher): void { - $dispatcher->addListener(Room::EVENT_BEFORE_SESSION_JOIN_CALL, static function (ModifyParticipantEvent $event) { - /** @var self $listener */ - $listener = \OC::$server->get(self::class); - $listener->checkStartCallPermissions($event); - }, 1000); + $dispatcher->addListener(Room::EVENT_BEFORE_SESSION_JOIN_CALL, [self::class, 'checkStartCallPermissions'], 1000); } /** * @param ModifyParticipantEvent $event * @throws ForbiddenException */ - public function checkStartCallPermissions(ModifyParticipantEvent $event): void { + public static function checkStartCallPermissions(ModifyParticipantEvent $event): void { + /** @var self $listener */ + $listener = \OC::$server->get(self::class); $room = $event->getRoom(); $participant = $event->getParticipant(); @@ -63,7 +61,7 @@ class RestrictStartingCalls { return; } - if (!$participant->canStartCall($this->config) && !$this->participantService->hasActiveSessionsInCall($room)) { + if (!$participant->canStartCall($listener->config) && !$listener->participantService->hasActiveSessionsInCall($room)) { throw new ForbiddenException('Can not start a call'); } } diff --git a/tests/php/Listener/RestrictStartingCallsTest.php b/tests/php/Listener/RestrictStartingCallsTest.php index b94da5a55..2ffbe04ab 100644 --- a/tests/php/Listener/RestrictStartingCallsTest.php +++ b/tests/php/Listener/RestrictStartingCallsTest.php @@ -97,7 +97,9 @@ class RestrictStartingCallsTest extends TestCase { $this->expectException(ForbiddenException::class); } + $this->overwriteService(RestrictStartingCalls::class, $this->listener); $this->listener->checkStartCallPermissions($event); + $this->restoreService(RestrictStartingCalls::class); if (!$throws) { self::assertTrue(true); |