|
36 | 36 | use OCP\IServerContainer; |
37 | 37 | use OCP\L10N\IFactory; |
38 | 38 | use OCP\Lock\LockedException; |
39 | | -use OCP\SpeechToText\ISpeechToTextManager; |
40 | 39 | use OCP\SpeechToText\ISpeechToTextProvider; |
41 | 40 | use OCP\SpeechToText\ISpeechToTextProviderWithId; |
42 | 41 | use OCP\TaskProcessing\EShapeType; |
@@ -96,9 +95,31 @@ public function __construct( |
96 | 95 | $this->appData = $appDataFactory->get('core'); |
97 | 96 | } |
98 | 97 |
|
| 98 | + |
| 99 | + /** |
| 100 | + * This is almost a copy of textProcessingManager->getProviders |
| 101 | + * to avoid a dependency cycle between TextProcessingManager and TaskProcessingManager |
| 102 | + */ |
99 | 103 | private function _getRawTextProcessingProviders(): array { |
100 | | - $textProcessingManager = \OCP\Server::get(\OCP\TextProcessing\IManager::class); |
101 | | - return $textProcessingManager->getProviders(); |
| 104 | + $context = $this->coordinator->getRegistrationContext(); |
| 105 | + if ($context === null) { |
| 106 | + return []; |
| 107 | + } |
| 108 | + |
| 109 | + $providers = []; |
| 110 | + |
| 111 | + foreach ($context->getTextProcessingProviders() as $providerServiceRegistration) { |
| 112 | + $class = $providerServiceRegistration->getService(); |
| 113 | + try { |
| 114 | + $providers[$class] = $this->serverContainer->get($class); |
| 115 | + } catch (\Throwable $e) { |
| 116 | + $this->logger->error('Failed to load Text processing provider ' . $class, [ |
| 117 | + 'exception' => $e, |
| 118 | + ]); |
| 119 | + } |
| 120 | + } |
| 121 | + |
| 122 | + return $providers; |
102 | 123 | } |
103 | 124 |
|
104 | 125 | private function _getTextProcessingProviders(): array { |
@@ -347,9 +368,28 @@ public function getOptionalOutputShapeEnumValues(): array { |
347 | 368 | return $newProviders; |
348 | 369 | } |
349 | 370 |
|
| 371 | + /** |
| 372 | + * This is almost a copy of SpeechToTextManager->getProviders |
| 373 | + * to avoid a dependency cycle between SpeechToTextManager and TaskProcessingManager |
| 374 | + */ |
350 | 375 | private function _getRawSpeechToTextProviders(): array { |
351 | | - $speechToTextManager = \OCP\Server::get(ISpeechToTextManager::class); |
352 | | - return $speechToTextManager->getProviders(); |
| 376 | + $context = $this->coordinator->getRegistrationContext(); |
| 377 | + if ($context === null) { |
| 378 | + return []; |
| 379 | + } |
| 380 | + $providers = []; |
| 381 | + foreach ($context->getSpeechToTextProviders() as $providerServiceRegistration) { |
| 382 | + $class = $providerServiceRegistration->getService(); |
| 383 | + try { |
| 384 | + $providers[$class] = $this->serverContainer->get($class); |
| 385 | + } catch (NotFoundExceptionInterface|ContainerExceptionInterface|\Throwable $e) { |
| 386 | + $this->logger->error('Failed to load SpeechToText provider ' . $class, [ |
| 387 | + 'exception' => $e, |
| 388 | + ]); |
| 389 | + } |
| 390 | + } |
| 391 | + |
| 392 | + return $providers; |
353 | 393 | } |
354 | 394 |
|
355 | 395 | /** |
|
0 commit comments