Files
IronKanban/public/api/create-project.php

35 lines
818 B
PHP

<?php
// phpcs:disable PEAR.Commenting.FileComment,PEAR.Commenting.ClassComment
/**
* Create a new project.
*/
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();
Http::json(
[
'success' => true,
'state' => $boardService->createProject(
trim((string) ($input['title'] ?? 'Untitled Project')),
trim((string) ($input['body'] ?? '')),
isset($input['slug']) ? trim((string) $input['slug']) : null
),
]
);
} catch (HttpHalt $halt) {
return;
} catch (Throwable $exception) {
Http::error($exception->getMessage(), 500);
}