Skip to content

Commit ae6f15c

Browse files
marcelklehrjulien-nc
authored andcommitted
Revert "fix(TaskProcessing): Use OCP\Server::get instead of copying methods"
This reverts commit d624c8d.
1 parent 08300e9 commit ae6f15c

File tree

1 file changed

+45
-5
lines changed

1 file changed

+45
-5
lines changed

lib/private/TaskProcessing/Manager.php

Lines changed: 45 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,6 @@
3636
use OCP\IServerContainer;
3737
use OCP\L10N\IFactory;
3838
use OCP\Lock\LockedException;
39-
use OCP\SpeechToText\ISpeechToTextManager;
4039
use OCP\SpeechToText\ISpeechToTextProvider;
4140
use OCP\SpeechToText\ISpeechToTextProviderWithId;
4241
use OCP\TaskProcessing\EShapeType;
@@ -96,9 +95,31 @@ public function __construct(
9695
$this->appData = $appDataFactory->get('core');
9796
}
9897

98+
99+
/**
100+
* This is almost a copy of textProcessingManager->getProviders
101+
* to avoid a dependency cycle between TextProcessingManager and TaskProcessingManager
102+
*/
99103
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;
102123
}
103124

104125
private function _getTextProcessingProviders(): array {
@@ -347,9 +368,28 @@ public function getOptionalOutputShapeEnumValues(): array {
347368
return $newProviders;
348369
}
349370

371+
/**
372+
* This is almost a copy of SpeechToTextManager->getProviders
373+
* to avoid a dependency cycle between SpeechToTextManager and TaskProcessingManager
374+
*/
350375
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;
353393
}
354394

355395
/**

0 commit comments

Comments
 (0)