Files
IronKanban/public/api/create-task.php
T
Keith Solomon 812e5c2f2a feature: Initial MVP
2026-04-05 16:20:39 -05:00

38 lines
979 B
PHP

<?php
// phpcs:disable PEAR.Commenting.FileComment,PEAR.Commenting.ClassComment
/**
* Create a new task.
*/
declare(strict_types=1);
$boardService = include __DIR__ . '/_bootstrap.php';
use IronKanban\Support\Http;
use IronKanban\Support\HttpHalt;
try {
Http::requireMethod('POST');
Http::verifyCsrf();
$input = Http::input();
$boardService->assertRevision((string) $input['projectId'], isset($input['revision']) ? (string) $input['revision'] : null);
Http::json(
[
'success' => true,
'state' => $boardService->createTask(
(string) $input['projectId'],
trim((string) ($input['title'] ?? 'Untitled Task')),
(string) ($input['column'] ?? 'backlog'),
(string) ($input['body'] ?? '')
),
]
);
} catch (HttpHalt $halt) {
return;
} catch (Throwable $exception) {
Http::error($exception->getMessage(), $exception->getMessage() === 'conflict' ? 409 : 500);
}