API refactoring

This commit is contained in:
Frederic Guillot
2015-05-23 21:44:33 -04:00
parent c9ba525bab
commit e32f26d048
24 changed files with 1519 additions and 606 deletions

51
app/Api/Comment.php Normal file
View File

@@ -0,0 +1,51 @@
<?php
namespace Api;
/**
* Comment API controller
*
* @package api
* @author Frederic Guillot
*/
class Comment extends Base
{
public function getComment($comment_id)
{
return $this->comment->getById($comment_id);
}
public function getAllComments($task_id)
{
return $this->comment->getAll($task_id);
}
public function removeComment($comment_id)
{
return $this->comment->remove($comment_id);
}
public function createComment($task_id, $user_id, $content)
{
$values = array(
'task_id' => $task_id,
'user_id' => $user_id,
'comment' => $content,
);
list($valid,) = $this->comment->validateCreation($values);
return $valid ? $this->comment->create($values) : false;
}
public function updateComment($id, $content)
{
$values = array(
'id' => $id,
'comment' => $content,
);
list($valid,) = $this->comment->validateModification($values);
return $valid && $this->comment->update($values);
}
}