Ejemplo n.º 1
0
 /**
  * @param \Chat\Bundle\CommonBundle\Entity\Chat $chat
  * @param array $hashList
  * @return array
  */
 public function getChatMessages(Chat $chat, $hashList = array())
 {
     $messages = $this->_em->getConnection()->fetchAll('
         SELECT 
             cm.id,
             cm.hash,
             cm.content,
             cm.createAt,
             m.username,
             m.textColor,
             m.backgroundColor
         FROM
             `chat_message` cm
         LEFT JOIN
             `chat_member` m ON m.id = cm.member_id
         WHERE
             cm.`chat_id` = :chat_id
             AND cm.hash NOT IN (' . implode(',', $hashList) . ')
         ORDER BY
             cm.create_at ASC
     ', array('chat_id' => $chat->getId()));
     foreach ($messages as $key => $value) {
         $createAt = new \DateTime($value['create_at']);
         $value['create_at'] = $createAt->format('m.d.y g:i a');
         $messages[$key] = $value;
     }
     return $messages;
 }
Ejemplo n.º 2
0
 /**
  * @param Chat|null $chat
  * @param Message|null $message
  * @param Message|null $inlineMessage
  * @param AbstractKeyboard|null $replyMarkup Reply keyboard markup
  */
 public function editMessageReplyMarkup($chat = null, $message = null, $inlineMessage = null, AbstractKeyboard $replyMarkup = null)
 {
     $params = ['chat_id' => $chat instanceof Chat ? $chat->getId() : $chat, 'message_id' => $message instanceof Message ? $message->getMessageId() : $message, 'inline_message_id' => $inlineMessage instanceof Message ? $inlineMessage->getMessageId() : $inlineMessage, 'reply_markup' => $replyMarkup];
     $this->getNet()->doRequest('/editMessageReplyMarkup', $params);
 }
Ejemplo n.º 3
0
 public function setChat(Chat $chat)
 {
     $this->setValue('chat', $chat->getId());
 }
Ejemplo n.º 4
0
 /**
  * Adds an object to the instance pool.
  *
  * Propel keeps cached copies of objects in an instance pool when they are retrieved
  * from the database.  In some cases -- especially when you override doSelect*()
  * methods in your stub classes -- you may need to explicitly add objects
  * to the cache in order to ensure that the same objects are always returned by doSelect*()
  * and retrieveByPK*() calls.
  *
  * @param      Chat $value A Chat object.
  * @param      string $key (optional) key to use for instance map (for performance boost if key was already calculated externally).
  */
 public static function addInstanceToPool(Chat $obj, $key = null)
 {
     if (Propel::isInstancePoolingEnabled()) {
         if ($key === null) {
             $key = (string) $obj->getId();
         }
         // if key === null
         self::$instances[$key] = $obj;
     }
 }