mirror of
https://github.com/pierre42100/ComunicAPI
synced 2025-06-19 00:25:18 +00:00
Upgraded API to use only Comments object instead of arrays
This commit is contained in:
@ -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();
|
@ -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;
|
||||
}
|
||||
|
Reference in New Issue
Block a user