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

github.com/nextcloud/spreed.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorVitor Mattos <vitor@php.rio>2022-04-19 17:33:49 +0300
committerVitor Mattos <vitor@php.rio>2022-04-19 17:33:49 +0300
commit8bd7f80c1177464c3ff36328e0691b81d9454ce4 (patch)
tree9b46fb1b497ce57ec4eaae70c1db935b082de9a4 /lib
parent9b9d30b9f7ef266af317c17ca33c157451027ba8 (diff)
Move command listener annonymous function to static
Signed-off-by: Vitor Mattos <vitor@php.rio>
Diffstat (limited to 'lib')
-rw-r--r--lib/Chat/Command/Listener.php56
1 files changed, 29 insertions, 27 deletions
diff --git a/lib/Chat/Command/Listener.php b/lib/Chat/Command/Listener.php
index de7a56807..bbdda8eda 100644
--- a/lib/Chat/Command/Listener.php
+++ b/lib/Chat/Command/Listener.php
@@ -41,33 +41,35 @@ class Listener {
}
public static function register(IEventDispatcher $dispatcher): void {
- $dispatcher->addListener(ChatManager::EVENT_BEFORE_MESSAGE_SEND, static function (ChatParticipantEvent $event) {
- $message = $event->getComment();
- $participant = $event->getParticipant();
-
- /** @var self $listener */
- $listener = \OC::$server->get(self::class);
-
- if (strpos($message->getMessage(), '//') === 0) {
- return;
- }
-
- try {
- /** @var Command $command */
- /** @var string $arguments */
- [$command, $arguments] = $listener->getCommand($message->getMessage());
- $command = $listener->commandService->resolveAlias($command);
- } catch (DoesNotExistException $e) {
- return;
- }
-
- if (!$listener->executor->isCommandAvailableForParticipant($command, $participant)) {
- $command = $listener->commandService->find('', 'help');
- $arguments = trim($message->getMessage());
- }
-
- $listener->executor->exec($event->getRoom(), $message, $command, $arguments, $participant);
- });
+ $dispatcher->addListener(ChatManager::EVENT_BEFORE_MESSAGE_SEND, [self::class, 'executeCommand']);
+ }
+
+ public static function executeCommand(ChatParticipantEvent $event): void {
+ $message = $event->getComment();
+ $participant = $event->getParticipant();
+
+ /** @var self $listener */
+ $listener = \OC::$server->get(self::class);
+
+ if (strpos($message->getMessage(), '//') === 0) {
+ return;
+ }
+
+ try {
+ /** @var Command $command */
+ /** @var string $arguments */
+ [$command, $arguments] = $listener->getCommand($message->getMessage());
+ $command = $listener->commandService->resolveAlias($command);
+ } catch (DoesNotExistException $e) {
+ return;
+ }
+
+ if (!$listener->executor->isCommandAvailableForParticipant($command, $participant)) {
+ $command = $listener->commandService->find('', 'help');
+ $arguments = trim($message->getMessage());
+ }
+
+ $listener->executor->exec($event->getRoom(), $message, $command, $arguments, $participant);
}
/**