]> source.dussan.org Git - nextcloud-server.git/commitdiff
Remove Task::factory method
authorMarcel Klehr <mklehr@gmx.net>
Wed, 19 Jul 2023 11:15:14 +0000 (13:15 +0200)
committerMarcel Klehr <mklehr@gmx.net>
Wed, 19 Jul 2023 11:15:14 +0000 (13:15 +0200)
Signed-off-by: Marcel Klehr <mklehr@gmx.net>
core/Controller/TextProcessingApiController.php
lib/private/TextProcessing/Db/Task.php
lib/public/TextProcessing/Task.php

index 0c723ebace3482b2ad52462e86d65cf48ff25a1e..58036fb25bc5362050bc24af5d1ae162b9392d82 100644 (file)
@@ -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);
                }
index bc1bbdc13dba0177b4b60aee1073589fc8078b86..8e800c76df8e3c7b272f11206870ab4b7a2224ce 100644 (file)
@@ -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());
index 668ca6d09c4a134a1a6fb6152374b276f3b20118..446e414cb045c34b12ebddb78895992f37a8948d 100644 (file)
@@ -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);
-       }
 }