Upgraded API to use only Comments object instead of arrays

This commit is contained in:
Pierre
2018-04-21 19:04:58 +02:00
parent a3b005d184
commit 3cfe5df2a7
3 changed files with 12 additions and 40 deletions

View File

@ -5,7 +5,7 @@
* @author Pierre HUBERT
*/
class commentsController {
class CommentsController {
/**
* Create a comment
@ -181,7 +181,7 @@ class commentsController {
* @param Comment $comment The comment to convert
* @return array Informations about the comment
*/
private function commentToAPI(Comment $comment) : array {
public static function commentToAPI(Comment $comment) : array {
$data = array();
$data["ID"] = $comment->get_id();

View File

@ -528,6 +528,14 @@ class postsController {
//Update visibility level
$infos['visibility_level'] = $this::VISIBILITY_LEVELS_API[$infos['visibility_level']];
//Parse comments if required
if(isset($infos['comments'])){
if($infos['comments'] != null){
foreach($infos['comments'] as $num=>$src)
$infos['comments'][$num] = CommentsController::commentToAPI($src);
}
}
//Return the post ready to be shown
return $infos;
}