From: Marcel Klehr Date: Wed, 19 Jul 2023 11:15:14 +0000 (+0200) Subject: Remove Task::factory method X-Git-Tag: v28.0.0beta1~664^2~2 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=7389567c7d05ba994533b7273cba1e5818a20b94;p=nextcloud-server.git Remove Task::factory method Signed-off-by: Marcel Klehr --- diff --git a/core/Controller/TextProcessingApiController.php b/core/Controller/TextProcessingApiController.php index 0c723ebace3..58036fb25bc 100644 --- a/core/Controller/TextProcessingApiController.php +++ b/core/Controller/TextProcessingApiController.php @@ -91,7 +91,7 @@ class TextProcessingApiController extends \OCP\AppFramework\OCSController { */ public function schedule(string $input, string $type, string $appId, string $identifier = ''): DataResponse { try { - $task = Task::factory($type, $input, $this->userId, $appId, $identifier); + $task = new Task($type, $input, $this->userId, $appId, $identifier); } catch (InvalidArgumentException) { return new DataResponse(['message' => $this->l->t('Requested task type does not exist')], Http::STATUS_BAD_REQUEST); } diff --git a/lib/private/TextProcessing/Db/Task.php b/lib/private/TextProcessing/Db/Task.php index bc1bbdc13db..8e800c76df8 100644 --- a/lib/private/TextProcessing/Db/Task.php +++ b/lib/private/TextProcessing/Db/Task.php @@ -103,7 +103,7 @@ class Task extends Entity { } public function toPublicTask(): OCPTask { - $task = OCPTask::factory($this->getType(), $this->getInput(), $this->getuserId(), $this->getAppId(), $this->getIdentifier()); + $task = new OCPTask($this->getType(), $this->getInput(), $this->getuserId(), $this->getAppId(), $this->getIdentifier()); $task->setId($this->getId()); $task->setStatus($this->getStatus()); $task->setOutput($this->getOutput()); diff --git a/lib/public/TextProcessing/Task.php b/lib/public/TextProcessing/Task.php index 668ca6d09c4..446e414cb04 100644 --- a/lib/public/TextProcessing/Task.php +++ b/lib/public/TextProcessing/Task.php @@ -218,21 +218,4 @@ final class Task implements \JsonSerializable { 'identifier' => $this->getIdentifier(), ]; } - - /** - * @param string $type - * @param string $input - * @param string|null $userId - * @param string $appId - * @param string $identifier - * @return Task - * @throws \InvalidArgumentException - * @since 27.1.0 - */ - final public static function factory(string $type, string $input, ?string $userId, string $appId, string $identifier = ''): Task { - if (!in_array($type, self::TYPES)) { - throw new \InvalidArgumentException('Unknown task type'); - } - return new Task($type, $input, $appId, $userId, $identifier); - } }