summaryrefslogtreecommitdiff
path: root/jsonrpc.php
diff options
context:
space:
mode:
authorFrédéric Guillot <fred@kanboard.net>2014-09-20 11:58:27 +0200
committerFrédéric Guillot <fred@kanboard.net>2014-09-20 11:58:27 +0200
commit5f96af82f26967f4614b89322a82a59cb48bd2a3 (patch)
tree98f527458d27f325cec7419dbb033b8f9f5f8b20 /jsonrpc.php
parent95e54d1d300809cb8656c52d029f797ba5961a04 (diff)
Split Task model into smaller classes
Diffstat (limited to 'jsonrpc.php')
-rw-r--r--jsonrpc.php10
1 files changed, 6 insertions, 4 deletions
diff --git a/jsonrpc.php b/jsonrpc.php
index 1f3cf650..a9c44747 100644
--- a/jsonrpc.php
+++ b/jsonrpc.php
@@ -6,6 +6,7 @@ use Core\Translator;
use JsonRPC\Server;
use Model\Project;
use Model\Task;
+use Model\TaskValidator;
use Model\User;
use Model\Config;
use Model\Category;
@@ -19,6 +20,7 @@ use Model\Notification;
$config = new Config($registry);
$project = new Project($registry);
$task = new Task($registry);
+$taskValidator = new TaskValidator($registry);
$user = new User($registry);
$category = new Category($registry);
$comment = new Comment($registry);
@@ -158,7 +160,7 @@ $server->register('allowUser', function($project_id, $user_id) use ($project) {
/**
* Task procedures
*/
-$server->register('createTask', function($title, $project_id, $color_id = '', $column_id = 0, $owner_id = 0, $creator_id = 0, $date_due = '', $description = '', $category_id = 0, $score = 0) use ($task) {
+$server->register('createTask', function($title, $project_id, $color_id = '', $column_id = 0, $owner_id = 0, $creator_id = 0, $date_due = '', $description = '', $category_id = 0, $score = 0) use ($task, $taskValidator) {
$values = array(
'title' => $title,
@@ -173,7 +175,7 @@ $server->register('createTask', function($title, $project_id, $color_id = '', $c
'score' => $score,
);
- list($valid,) = $task->validateCreation($values);
+ list($valid,) = $taskValidator->validateCreation($values);
return $valid && $task->create($values) !== false;
});
@@ -185,7 +187,7 @@ $server->register('getAllTasks', function($project_id, $status) use ($task) {
return $task->getAll($project_id, $status);
});
-$server->register('updateTask', function($id, $title = null, $project_id = null, $color_id = null, $column_id = null, $owner_id = null, $creator_id = null, $date_due = null, $description = null, $category_id = null, $score = null) use ($task) {
+$server->register('updateTask', function($id, $title = null, $project_id = null, $color_id = null, $column_id = null, $owner_id = null, $creator_id = null, $date_due = null, $description = null, $category_id = null, $score = null) use ($task, $taskValidator) {
$values = array(
'id' => $id,
@@ -207,7 +209,7 @@ $server->register('updateTask', function($id, $title = null, $project_id = null,
}
}
- list($valid) = $task->validateModification($values);
+ list($valid) = $taskValidator->validateModification($values);
return $valid && $task->update($values);
});