Skip to content

Commit d624c8d

Browse files
committed
fix(TaskProcessing): Use OCP\Server::get instead of copying methods
Signed-off-by: Marcel Klehr <mklehr@gmx.net>
1 parent 7c321eb commit d624c8d

File tree

1 file changed

+5
-45
lines changed

1 file changed

+5
-45
lines changed

lib/private/TaskProcessing/Manager.php

+5-45
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@
3636
use OCP\IServerContainer;
3737
use OCP\L10N\IFactory;
3838
use OCP\Lock\LockedException;
39+
use OCP\SpeechToText\ISpeechToTextManager;
3940
use OCP\SpeechToText\ISpeechToTextProvider;
4041
use OCP\SpeechToText\ISpeechToTextProviderWithId;
4142
use OCP\TaskProcessing\EShapeType;
@@ -95,31 +96,9 @@ public function __construct(
9596
$this->appData = $appDataFactory->get('core');
9697
}
9798

98-
99-
/**
100-
* This is almost a copy of textProcessingManager->getProviders
101-
* to avoid a dependency cycle between TextProcessingManager and TaskProcessingManager
102-
*/
10399
private function _getRawTextProcessingProviders(): array {
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;
100+
$textProcessingManager = \OCP\Server::get(\OCP\TextProcessing\IManager::class);
101+
return $textProcessingManager->getProviders();
123102
}
124103

125104
private function _getTextProcessingProviders(): array {
@@ -368,28 +347,9 @@ public function getOptionalOutputShapeEnumValues(): array {
368347
return $newProviders;
369348
}
370349

371-
/**
372-
* This is almost a copy of SpeechToTextManager->getProviders
373-
* to avoid a dependency cycle between SpeechToTextManager and TaskProcessingManager
374-
*/
375350
private function _getRawSpeechToTextProviders(): array {
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;
351+
$speechToTextManager = \OCP\Server::get(ISpeechToTextManager::class);
352+
return $speechToTextManager->getProviders();
393353
}
394354

395355
/**

0 commit comments

Comments
 (0)