Merge pull request #42762 from nextcloud/enh/text-to-image-provider-with-userid

enh(OCP\TextToImage): Introduce IProviderWithUserId
pull/42781/head
Alexander Piskun 5 months ago committed by GitHub
commit 7fdb16affc
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -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',

@ -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',

@ -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])) {

@ -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;
}
Loading…
Cancel
Save