]> source.dussan.org Git - nextcloud-server.git/commitdiff
fix(TaskProcessing): Use OCP\Server::get instead of copying methods
authorMarcel Klehr <mklehr@gmx.net>
Fri, 30 Aug 2024 06:26:55 +0000 (08:26 +0200)
committerJulien Veyssier <julien-nc@posteo.net>
Fri, 30 Aug 2024 12:06:15 +0000 (14:06 +0200)
Signed-off-by: Marcel Klehr <mklehr@gmx.net>
Signed-off-by: Julien Veyssier <julien-nc@posteo.net>
lib/private/TaskProcessing/Manager.php

index 5316414e8fb9f98c6a8c26836c7fe9de8a5eee23..634a50ac7e675d9bc8a42e4f317afd6cf786b731 100644 (file)
@@ -36,6 +36,7 @@ use OCP\IL10N;
 use OCP\IServerContainer;
 use OCP\L10N\IFactory;
 use OCP\Lock\LockedException;
+use OCP\SpeechToText\ISpeechToTextManager;
 use OCP\SpeechToText\ISpeechToTextProvider;
 use OCP\SpeechToText\ISpeechToTextProviderWithId;
 use OCP\TaskProcessing\EShapeType;
@@ -95,31 +96,9 @@ class Manager implements IManager {
                $this->appData = $appDataFactory->get('core');
        }
 
-
-       /**
-        * This is almost a copy of textProcessingManager->getProviders
-        * to avoid a dependency cycle between TextProcessingManager and TaskProcessingManager
-        */
        private function _getRawTextProcessingProviders(): array {
-               $context = $this->coordinator->getRegistrationContext();
-               if ($context === null) {
-                       return [];
-               }
-
-               $providers = [];
-
-               foreach ($context->getTextProcessingProviders() as $providerServiceRegistration) {
-                       $class = $providerServiceRegistration->getService();
-                       try {
-                               $providers[$class] = $this->serverContainer->get($class);
-                       } catch (\Throwable $e) {
-                               $this->logger->error('Failed to load Text processing provider ' . $class, [
-                                       'exception' => $e,
-                               ]);
-                       }
-               }
-
-               return $providers;
+               $textProcessingManager = \OCP\Server::get(\OCP\TextProcessing\IManager::class);
+               return $textProcessingManager->getProviders();
        }
 
        private function _getTextProcessingProviders(): array {
@@ -368,28 +347,9 @@ class Manager implements IManager {
                return $newProviders;
        }
 
-       /**
-        * This is almost a copy of SpeechToTextManager->getProviders
-        * to avoid a dependency cycle between SpeechToTextManager and TaskProcessingManager
-        */
        private function _getRawSpeechToTextProviders(): array {
-               $context = $this->coordinator->getRegistrationContext();
-               if ($context === null) {
-                       return [];
-               }
-               $providers = [];
-               foreach ($context->getSpeechToTextProviders() as $providerServiceRegistration) {
-                       $class = $providerServiceRegistration->getService();
-                       try {
-                               $providers[$class] = $this->serverContainer->get($class);
-                       } catch (NotFoundExceptionInterface|ContainerExceptionInterface|\Throwable $e) {
-                               $this->logger->error('Failed to load SpeechToText provider ' . $class, [
-                                       'exception' => $e,
-                               ]);
-                       }
-               }
-
-               return $providers;
+               $speechToTextManager = \OCP\Server::get(ISpeechToTextManager::class);
+               return $speechToTextManager->getProviders();
        }
 
        /**