Skip to content

Commit

Permalink
Revert "fix(TaskProcessing): Use OCP\Server::get instead of copying m…
Browse files Browse the repository at this point in the history
…ethods"

This reverts commit d624c8d.
  • Loading branch information
marcelklehr authored and julien-nc committed Aug 30, 2024
1 parent 08300e9 commit ae6f15c
Showing 1 changed file with 45 additions and 5 deletions.
50 changes: 45 additions & 5 deletions lib/private/TaskProcessing/Manager.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@
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;
Expand Down Expand Up @@ -96,9 +95,31 @@ public function __construct(
$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 {
Expand Down Expand Up @@ -347,9 +368,28 @@ public function getOptionalOutputShapeEnumValues(): array {
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;
}

/**
Expand Down

0 comments on commit ae6f15c

Please sign in to comment.