From f39d1622771f69605bbc955168f9b730ac27faea Mon Sep 17 00:00:00 2001 From: Pierre Date: Mon, 23 Apr 2018 19:12:49 +0200 Subject: [PATCH] Moved conversations classes --- ...roller.php => ConversationsController.php} | 22 ++++++++++++++++++- .../{conversations.php => Conversations.php} | 4 ++-- 2 files changed, 23 insertions(+), 3 deletions(-) rename RestControllers/{conversationsController.php => ConversationsController.php} (95%) rename classes/components/{conversations.php => Conversations.php} (99%) diff --git a/RestControllers/conversationsController.php b/RestControllers/ConversationsController.php similarity index 95% rename from RestControllers/conversationsController.php rename to RestControllers/ConversationsController.php index 6fce15f..1910c7b 100644 --- a/RestControllers/conversationsController.php +++ b/RestControllers/ConversationsController.php @@ -5,7 +5,7 @@ * @author Pierre HUBERT */ -class conversationsController{ +class ConversationsController{ /** * Get the conversations list @@ -460,4 +460,24 @@ class conversationsController{ return $data; } + + /** + * Turn ConversationMessage object into API entry + * + * @param ConversationMessage $message The message to convert + * @return array Valid dataset for the api + */ + private static function ConvMessageToAPI(ConversationMessage $message) : array { + + $data = array(); + + $data["ID"] = $message->get_id(); + $data["ID_user"] = $message->get_userID(); + $data["time_insert"] = $message->get_time_sent(); + $data["message"] = $message->has_message() ? $message->get_message() : ""; + $data["image_path"] = $message->has_image_path() ? $message->get_image_path() : null; + + return $data; + + } } \ No newline at end of file diff --git a/classes/components/conversations.php b/classes/components/Conversations.php similarity index 99% rename from classes/components/conversations.php rename to classes/components/Conversations.php index e137925..ab9fb01 100644 --- a/classes/components/conversations.php +++ b/classes/components/Conversations.php @@ -5,7 +5,7 @@ * @author Pierre HUBERT */ -class conversations { +class Conversations { /** * @var String $conversationsListTable Name of the conversation list table @@ -874,4 +874,4 @@ class conversations { } //Register component -Components::register("conversations", new conversations()); \ No newline at end of file +Components::register("conversations", new Conversations()); \ No newline at end of file