aboutsummaryrefslogtreecommitdiffstats
path: root/lib/private
diff options
context:
space:
mode:
authorMarcel Klehr <mklehr@gmx.net>2024-08-30 10:01:21 +0200
committerJulien Veyssier <julien-nc@posteo.net>2024-08-30 14:06:15 +0200
commit133b396a1ef5bd21daebe39ea0e157c49fe39d32 (patch)
treedac309193a8cb8c99b9b57d85777bafa49834d07 /lib/private
parent77464a4a0d7948e86569d1f936abc8c18968c555 (diff)
downloadnextcloud-server-133b396a1ef5bd21daebe39ea0e157c49fe39d32.tar.gz
nextcloud-server-133b396a1ef5bd21daebe39ea0e157c49fe39d32.zip
Revert "fix(TaskProcessing): Use OCP\Server::get instead of copying methods"
This reverts commit d624c8da8f0dc2eaf18d416aa15db0a2035de398. Signed-off-by: Julien Veyssier <julien-nc@posteo.net>
Diffstat (limited to 'lib/private')
-rw-r--r--lib/private/TaskProcessing/Manager.php50
1 files changed, 45 insertions, 5 deletions
diff --git a/lib/private/TaskProcessing/Manager.php b/lib/private/TaskProcessing/Manager.php
index 634a50ac7e6..5316414e8fb 100644
--- a/lib/private/TaskProcessing/Manager.php
+++ b/lib/private/TaskProcessing/Manager.php
@@ -36,7 +36,6 @@ 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;
@@ -96,9 +95,31 @@ 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 {
- $textProcessingManager = \OCP\Server::get(\OCP\TextProcessing\IManager::class);
- return $textProcessingManager->getProviders();
+ $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;
}
private function _getTextProcessingProviders(): array {
@@ -347,9 +368,28 @@ 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 {
- $speechToTextManager = \OCP\Server::get(ISpeechToTextManager::class);
- return $speechToTextManager->getProviders();
+ $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;
}
/**