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

38 lines
951 B
PHP

<?php
// phpcs:disable PEAR.Commenting.FileComment,PEAR.Commenting.ClassComment
/**
* Move a task between columns.
*/
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->moveTask(
(string) $input['projectId'],
(string) $input['taskId'],
(string) $input['column'],
max(0, (int) ($input['index'] ?? 0))
),
]
);
} catch (HttpHalt $halt) {
return;
} catch (Throwable $exception) {
Http::error($exception->getMessage(), $exception->getMessage() === 'conflict' ? 409 : 500);
}