introduce IProviderWithUserId

Signed-off-by: Andrey Borysenko <andrey18106x@gmail.com>
Signed-off-by: Alexander Piskun <bigcat88@icloud.com>
This commit is contained in:
Alexander Piskun 2024-01-14 19:42:58 +02:00
parent eaa6d96cf7
commit 156013a711
No known key found for this signature in database
GPG Key ID: 1F0BF0EC3CF22721
4 changed files with 21 additions and 0 deletions

View File

@ -706,6 +706,7 @@ return array(
'OCP\\TextToImage\\Exception\\TextToImageException' => $baseDir . '/lib/public/TextToImage/Exception/TextToImageException.php',
'OCP\\TextToImage\\IManager' => $baseDir . '/lib/public/TextToImage/IManager.php',
'OCP\\TextToImage\\IProvider' => $baseDir . '/lib/public/TextToImage/IProvider.php',
'OCP\\TextToImage\\IProviderWithUserId' => $baseDir . '/lib/public/TextToImage/IProviderWithUserId.php',
'OCP\\TextToImage\\Task' => $baseDir . '/lib/public/TextToImage/Task.php',
'OCP\\Translation\\CouldNotTranslateException' => $baseDir . '/lib/public/Translation/CouldNotTranslateException.php',
'OCP\\Translation\\IDetectLanguageProvider' => $baseDir . '/lib/public/Translation/IDetectLanguageProvider.php',

View File

@ -739,6 +739,7 @@ class ComposerStaticInit749170dad3f5e7f9ca158f5a9f04f6a2
'OCP\\TextToImage\\Exception\\TextToImageException' => __DIR__ . '/../../..' . '/lib/public/TextToImage/Exception/TextToImageException.php',
'OCP\\TextToImage\\IManager' => __DIR__ . '/../../..' . '/lib/public/TextToImage/IManager.php',
'OCP\\TextToImage\\IProvider' => __DIR__ . '/../../..' . '/lib/public/TextToImage/IProvider.php',
'OCP\\TextToImage\\IProviderWithUserId' => __DIR__ . '/../../..' . '/lib/public/TextToImage/IProviderWithUserId.php',
'OCP\\TextToImage\\Task' => __DIR__ . '/../../..' . '/lib/public/TextToImage/Task.php',
'OCP\\Translation\\CouldNotTranslateException' => __DIR__ . '/../../..' . '/lib/public/Translation/CouldNotTranslateException.php',
'OCP\\Translation\\IDetectLanguageProvider' => __DIR__ . '/../../..' . '/lib/public/Translation/IDetectLanguageProvider.php',

View File

@ -43,6 +43,7 @@ use OCP\TextToImage\Exception\TaskFailureException;
use OCP\TextToImage\Exception\TaskNotFoundException;
use OCP\TextToImage\IManager;
use OCP\TextToImage\IProvider;
use OCP\TextToImage\IProviderWithUserId;
use OCP\TextToImage\Task;
use Psr\Log\LoggerInterface;
use RuntimeException;
@ -158,6 +159,9 @@ class Manager implements IManager {
}
}
$this->logger->debug('Calling Text2Image provider\'s generate method');
if ($provider instanceof IProviderWithUserId) {
$provider->setUserId($task->getUserId());
}
$provider->generate($task->getInput(), $resources);
for ($i = 0; $i < $task->getNumberOfImages(); $i++) {
if (is_resource($resources[$i])) {

View File

@ -0,0 +1,15 @@
<?php
declare(strict_types=1);
namespace OCP\TextToImage;
/**
* @since 29.0.0
*/
interface IProviderWithUserId extends IProvider {
/**
* @since 29.0.0
*/
public function setUserId(?string $userId): void;
}