Remove Task::factory method

Signed-off-by: Marcel Klehr <mklehr@gmx.net>
(cherry picked from commit 7389567c7d)
This commit is contained in:
Marcel Klehr 2023-07-19 13:15:14 +02:00
parent 96ec6ff5ea
commit 00e3fb143f
3 changed files with 2 additions and 19 deletions

View 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);
}

View 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());

View 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);
}
}