Longman\TelegramBot\Entities\Message::getEntities PHP Method

getEntities() public method

This method overrides the default getEntities method and returns a nice array of MessageEntity objects.
public getEntities ( ) : null | MessageEntity[]
return null | MessageEntity[]
    public function getEntities()
    {
        $pretty_array = $this->makePrettyObjectArray(MessageEntity::class, 'entities');
        return empty($pretty_array) ? null : $pretty_array;
    }

Usage Example

Exemplo n.º 1
0
 /**
  * Insert Edited Message request in db
  *
  * @param \Longman\TelegramBot\Entities\Message $edited_message
  *
  * @return bool If the insert was successful
  * @throws \Longman\TelegramBot\Exception\TelegramException
  */
 public static function insertEditedMessageRequest(Message $edited_message)
 {
     if (!self::isDbConnected()) {
         return false;
     }
     $from = $edited_message->getFrom();
     $chat = $edited_message->getChat();
     $chat_id = $chat->getId();
     $edit_date = self::getTimestamp($edited_message->getEditDate());
     $entities = self::entitiesArrayToJson($edited_message->getEntities(), null);
     //Insert chat
     self::insertChat($chat, $edit_date);
     //Insert user and the relation with the chat
     if (is_object($from)) {
         self::insertUser($from, $edit_date, $chat);
     }
     try {
         $sth = self::$pdo->prepare('
             INSERT IGNORE INTO `' . TB_EDITED_MESSAGE . '`
             (`chat_id`, `message_id`, `user_id`, `edit_date`, `text`, `entities`, `caption`)
             VALUES
             (:chat_id, :message_id, :user_id, :date, :text, :entities, :caption)
         ');
         $message_id = $edited_message->getMessageId();
         if (is_object($from)) {
             $from_id = $from->getId();
         } else {
             $from_id = null;
         }
         $text = $edited_message->getText();
         $caption = $edited_message->getCaption();
         $sth->bindParam(':chat_id', $chat_id, PDO::PARAM_INT);
         $sth->bindParam(':message_id', $message_id, PDO::PARAM_INT);
         $sth->bindParam(':user_id', $from_id, PDO::PARAM_INT);
         $sth->bindParam(':date', $edit_date, PDO::PARAM_STR);
         $sth->bindParam(':text', $text, PDO::PARAM_STR);
         $sth->bindParam(':entities', $entities, PDO::PARAM_STR);
         $sth->bindParam(':caption', $caption, PDO::PARAM_STR);
         return $sth->execute();
     } catch (PDOException $e) {
         throw new TelegramException($e->getMessage());
     }
 }
All Usage Examples Of Longman\TelegramBot\Entities\Message::getEntities